JS this作用域以及GET传输值过长的问题解决方法
2013-08-06 00:00
656 查看
在开发项目的时候,前端遇到两个比较隐蔽的问题。
问题一.专IE7浏览器,IE URL参数过长问题,引发HTTP Status 122报错
原因:在IE6.8下没有什么问题,但在IE7就不兼容get参数过长,google上说“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”
解决方法:
把原项目采用jsonp get的数据方法改为 常规post数据方法
问题二. this作用域问题
原因:this如果不是在对象内部默认为是 window这个大对象,如下面的this如是放在一个ajax的里面指的是当前域名ajax对象
解决方法:
解决方法:
问题一.专IE7浏览器,IE URL参数过长问题,引发HTTP Status 122报错
原因:在IE6.8下没有什么问题,但在IE7就不兼容get参数过长,google上说“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”
解决方法:
把原项目采用jsonp get的数据方法改为 常规post数据方法
问题二. this作用域问题
原因:this如果不是在对象内部默认为是 window这个大对象,如下面的this如是放在一个ajax的里面指的是当前域名ajax对象
解决方法:
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); //等于undefine } }); }
解决方法:
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 } }); }
相关文章推荐
- JS this作用域以及GET传输值过长的问题解决方法
- JS this作用域以及GET传输值过长的问题
- 关于Servlet报错:405 HTTP method GET is not supported by this URL问题解决方法
- IE 下js里面new Date("2017-07-11 08:00:00") 出现NAN的问题以及解决方法
- js addEventListener和attachEvent函数中的this的指向问题及解决方法
- 根据原生JS封装函数,根据传递的选择器查找对应的元素以及解决getElementsByClassName() 兼容问题
- IE 下js里面new Date("2017-07-11 08:00:00") 出现NAN的问题以及解决方法
- Angularjs MVC 以及 $scope 作用域 Angularjs 模块 的 run 方法 以及依赖注入中代码压缩问题
- js绑定事件this指向发生改变的问题解决方法
- json传递中文乱码解决方法以及解决request.getParameter()获取参数为乱码的问题
- IE 下js里面new Date("2011-11-11") 出现nan的问题以及解决方法
- 解决servlet中输出中文到浏览器以及post、get两种提交方法乱码问题
- bind方法解决this作用域问题
- js学习总结之DOM2兼容处理this问题的解决方法
- js绑定事件this指向发生改变的问题解决方法
- js,css三种方法解决IE6下position:fixed的Bug以及闪动问题
- 程序中和有js函数的网页交互,线程中调用 get_Script 就会错误的解决方法,由于COM的线程安全问题
- 关于js get请求参数过长导不出execl 文件 post解决方法
- 解决get方法传递URL参数中文乱码问题
- mac使用mysql出现的一些问题以及解决方法