jQuery XMLHttpRequest错误

在jQuery中有一个未定义的Ajax请求错误.但它在本地工作.在 jquery1.3.2.js @ 3633行中引用错误
xhr.send(s.data);

我的代码是:

$.ajax({
    type: "POST",url: 'index.PHP',data: "action=showpath&type=images&path=&default=1",cache: false,dataType: "html",success: function(data){
        $('#addr').html(data);
    },error:function (xhr,ajaxOptions,thrownError){
            alert(xhr.status);
            alert(thrownError);
    }       
});

代码中的警报显示我(0,’undefined’);

我做错了什么?

解决方法

如果您的ajax请求在完成之前被取消,则可能会发生这种情况.当用户通过刷新,点击链接或在浏览器中更改URL来导航时,jQuery会抛出错误事件.您可以通过实现ajax调用错误处理程序并检查xmlHttpRequest对象来检测这些类型的错误
$.ajax({
    /* ajax options omitted */
    error: function (xmlHttpRequest,textStatus,errorThrown) {
         if(xmlHttpRequest.readyState == 0 || xmlHttpRequest.status == 0) 
              return;  // it's not really an error
         else
              // Do normal error handling
});

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...