下边是请求的jquery代码 下边这个代码在IE8中可以使用,但在firefox中却无返回值!! $.get("/Manage/user.aspx?asyn=1" ,function(data,status){
if (data!="")
{
parent.document.getElementById('Lb_msgnum').innerHTML = data; // xmlhttp.responseText;
}
alert(data); //这句是空值 data.length为0
alert(status);//显示 成功
},"text")
user.aspx中的代码 //ajax异步刷新消息数量
if (!string.IsNullOrEmpty(Request.QueryString["asyn"]))
{ Response.ContentType = "application/text";
Response.Write(Lb_msgnum.Text);
Response.End();
}
if (data!="")
{
parent.document.getElementById('Lb_msgnum').innerHTML = data; // xmlhttp.responseText;
}
alert(data); //这句是空值 data.length为0
alert(status);//显示 成功
},"text")
user.aspx中的代码 //ajax异步刷新消息数量
if (!string.IsNullOrEmpty(Request.QueryString["asyn"]))
{ Response.ContentType = "application/text";
Response.Write(Lb_msgnum.Text);
Response.End();
}
{
parent.document.getElementById('Lb_msgnum').innerHTML = data; // xmlhttp.responseText;
alert( parent.document.getElementById('Lb_msgnum').innerHTML );//看看在FF能不能显示出值。
}
//Response.ContentType = "application/text";
Response.Write(Lb_msgnum.Text);
//Response.End();
注释掉试试
GET http://localhost:91/Manage/user.aspx?asyn=1 这后面有个红叉,请求到的页面出的错。。但在IE却又是可以执行的,是字符编码还是我在user.aspx 下代码出的问题!!
if (!string.IsNullOrEmpty(Request.QueryString["asyn"]))
{
Response.ContentType = "application/text";
Response.Write(Lb_msgnum.Text);
Response.End();
}
jquery....min.js (line 130)
ParamsHeadersPostPutResponseCacheHTMLasyn 1 这是parmar的值
下面是Headers的值
Response Headersview source
Request Headersview source
Host localhost:91
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4
Accept text/plain, */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
X-Requested-With XMLHttpRequest
Referer http://localhost:91/Manage/FriendManage/FriendMsgList.aspx
Cookie ASP.NET_SessionId=z2girh45ue5m3s553g5gqc55
//
response的值为 空
Response.Write(Lb_msgnum.Text);
Response.End();
Lb_msgnum.Text 这个是一个服务器控件?你换成一个常量试试!ajax 后台处理是获取不到视图状态的!
我还发现在firefox中status为0,在IE就是200这是什么原因啊。
Response.Write(Lb_msgnum.Text);
Response.End();
我想这也就是为什么responseText返回为空字符串的原因了吧,但是很奇怪IE中就没有这样!!
xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null ); 这个我真不知道是什么意思!!IE下就能用,而且我用得是fromvaidation的框架在这里用ajax也是可行的。自己写的jquery反倒是不行了!!