jquery ajax status=0,jquery ajax error {“readyState”:0,“responseText”:“”,“status”:0,“statusText”:“er...

这篇博客探讨了在进行Ajax请求时遇到的问题,请求返回的状态为0,错误信息显示为'error'。作者检查了请求头,并对比了一个在同一网站上成功执行的请求头。尽管尝试了提供完整URL,问题仍然存在。博客内容可能涉及跨域请求、请求头设置、服务器配置等方面,但作者已经排除了这些可能性。寻求解决方案的过程中,作者发现另一个页面上的类似请求能正常工作,暗示问题可能与具体请求参数或服务器响应有关。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I am trying to do an ajax request $.ajax({type:"post",url:"download.php",error:function(data,status,err){alert(JSON.stringify(data));},data:"fileid="+fileid});

this request alerts "{"readyState":0,"responseText":"","status":0,"statusText":"error"}"

I have searched on google all i have come up with is a cross site ajax call(which this is obviously not)

I have tried putting the full url in and it does the same thing.

the only thing i can think of is the header and i don't know what would be wrong with it. Here is the request header from firebug Hostwww.mydomain.comUser-AgentMozilla/5.0(WindowsNT6.1;rv:5.0)Gecko/20100101Firefox/5.0Accept*/* 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 Connection keep-alive Content-Type application/x-www-form-urlencoded; charset=UTF-8 X-Requested-With XMLHttpRequest Referer http://www.mydomain.com/ Content-Length 8 Cookie PHPSESSID=27b7d3890b82345a4fc9604808acd928

I have added another request on a different page and it works just fine but this one keeps failing the header for the other request is: Hostwww.mydomain.comUser-AgentMozilla/5.0(WindowsNT6.1;rv:5.0)Gecko/20100101Firefox/5.0Accepttext/plain,*/*; q=0.01 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 Connection keep-alive Content-Type application/x-www-form-urlencoded; charset=UTF-8 X-Requested-With XMLHttpRequest Referer http://www.mydomain.com/differentpage.php Content-Length 33 Cookie PHPSESSID=27b7d3890b82345a4fc9604808acd928

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值