JS this作用域以及GET传输值过长的问题
来源:互联网 发布:mac 设置输入法皮肤吗 编辑:程序博客网 时间:2024/05/29 01:55
在开发项目的时候,前端遇到两个比较隐蔽的问题。
问题一.专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对象
解决方法:
PHP Code复制内容到剪贴板
- 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作用域问题
- JS中this的作用域问题
- JS中setTimeout的作用域以及this的指向问题
- setTimeout的作用域以及this的指向问题
- JavaScript中setTimeout的作用域以及this指向问题
- js this作用域问题讲解
- 作用域以及this
- JS this作用域
- js中this的作用域
- JS的作用域、闭包原理以及性能问题
- JS中的作用域以及全局变量的问题
- js变量声明以及作用域的问题
- 【javascript 技巧】谈谈setTimeout的作用域以及this的指向问题
- js中this的作用
- JS中this的作用
- 关于JS中for循环时,作用域问题和this指针指向的总结
- 关于js中的作用域和作用域链以及常见的问题和结果方法
- 浅谈android的selector背景选择器
- ===《c/c++笔记》===向量容器
- web.config的配置(一)
- 关于Tomcat 不能识别 Eclipse工作区间 Java web 工程
- Eclipse CDT launch failed.Binary not found解决方案
- JS this作用域以及GET传输值过长的问题
- python3.x 对 python2.x 语法变动
- 前线解释多线程《二》
- Android ImageView图片自适应
- c文件操作 (转)
- 利用JDBC访问dept表
- hdu4355(三分法)
- replace和replaceAll
- JavaScript 闭包究竟是什么