最近用Ajax来做一个东东,可是在IE8中没错误,IE6、7都出现了错误,最终确认是因为url长度的问题,我的url长度很大有超过4000个字节,而ie6、7不支持这样长的url,ie8是可以,这样就导致了两个问题:

以下将这个长度很长的url简称myurl,且在两个页面都要用到它长长的querystring

1,用模式对话框打开新窗体,即showModalDialog是url过长,ie6、ie7打开的页面出错

2,用ajax的get方法请求另外一个页面ie6、ie7均失败

解决方案:

1,通过showModalDialog的第二个参数,将包含常常的querystring里边的绝大部分内容传到模式对话框,

var result = openDialog(url, input, 600, 400, 'status:yes;help:yes;scroll:yes');//这里的inpu是包含那部分常常内容的input

而模式对话框的页面通过document.getElementById('HiddenXml').value=window.dialogArguments.value;来获取值window.dialogArguments.value,这在ie6、7、8、Firefox3.5下均正常

2,ajax使用post的方法而不是get的方法

if(method=='POST')
{
xml.setRequestHeader("Content-Length",queryString.length);
}
xml.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

记得一定要设置请求头部的content-length和conten-type


About author
Disclaimer
The opinions and comments expressed herein are my own personal opinions and do not represent my employer's view in any way.
Comments
No comments.
Add comment
Title
Title is required.
Name
Name is required.
Email
Please input your personal email with valid format.
Comments
Please input comment content.
Captcha Refresh
Input captcha:

Subscription

Statistics

Locations of visitors to this page