JSthis scope and the problem of too long GET transfer value _ javascript skills

Source: Internet
Author: User
The IEURL parameter in the IE7 browser is too long, causing an error in HTTPStatus122. For this scope problem, the corresponding solution is as follows. If you are interested, refer, I hope it will be helpful to you. When developing projects, the front-end will encounter two hidden 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:

The Code is as follows:


Var test = {};
Test. getflash = 2;
Test. test = function (){
Alert (this. getflash); // 2
$. Ajax ({
Type: "POST ",
Url: "some. php ",
Data: "name = John & location = Boston ",
Success: function (msg ){
Alert (this. getflash); // equals to undefine
}
});
}


Solution:

The Code is as follows:


Test. test = function (){
Var thisValue = this;
Alert (thisValue. getflash); // 2
$. Ajax ({
Type: "POST ",
Url: "some. php ",
Data: "name = John & location = Boston ",
Success: function (msg ){
Alert (thisValue. getflash); // 2
}
});
}

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.