JS this scope and get Transmission Value Too Long

Source: Internet
Author: User

During the development project, the front-end encountered two concealed problems.
Problem 1: The ie url parameter in the IE7 browser is too long, causing an HTTP status 122 error.
Cause: there is no problem in ie6.8, but the get parameter is too long in IE7. Google says, "Don't use the get method in Ajax apps, if you can void it, because IE7 craps out with more than 2032 characters in a get string"
Solution:
Change the jsonp get data method of the original project to the conventional post data method.

Question 2. This scope Problem
Cause: if this is not a large window object in the object, this indicates the Ajax object of the current domain name.
Solution:
 

Copy content from PHP code to clipboard
  1. VaR test = {};
  2. Test. getflash = 2;
  3. Test. Test = function (){
  4. Alert (this. getflash); // 2
  5. $. Ajax ({
  6. Type: "Post ",
  7. URL: "Some. php ",
  8. Data: "name = John & location = Boston ",
  9. Success: function (MSG ){
  10. Alert (this. getflash); // equals to undefine
  11. }
  12. });
  13. }
  14. Solution:
  15. Test. Test = function (){
  16. VaR thisvalue = this;
  17. Alert (thisvalue. getflash); // 2
  18. $. Ajax ({
  19. Type: "Post ",
  20. URL: "Some. php ",
  21. Data: "name = John & location = Boston ",
  22. Success: function (MSG ){
  23. Alert (thisvalue. getflash); // 2
  24. }
  25. });
  26. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.