weixin_33724659 2012-03-12 20:36 采纳率: 0%
浏览 19

jQuery状态200正常错误[关闭]

                <div class="grid--cell fl1 lh-lg">
                    <div class="grid--cell fl1 lh-lg">
                        As it currently stands, this question is not a good fit for our Q&amp;A format. We expect answers to be supported by facts, references,   or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question   can be improved and possibly reopened, <a href="/help/reopen-questions">visit the help center</a> for guidance.

                    </div>
                </div>
            </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2012-03-15 09:18:40Z" class="relativetime">8 years ago</span>.</div>
        </div>
    </aside>

I have a very special problem with jQuery ajax requests.

when a user is browsig various parts of the webpage, there are jquery get() calls to fetch some content. The thing is that those requests stop working on random occasions. When I check the request response in firebug, the request status is 200 OK, but the firebug request is colored as red as in there was an error, but there is no error message.

The response tab in firebug is empty.

The thing is that is I visit those urls normally, not thought ajax, the content is returned normally.

So if I restart the browser it's all good again, I'm using jquery 1.7.1 and jquery.effects.core.js

Here's where I make the request:

$.get('abc', function(data) {
...
}).error(function(xhr, status, error) { alert("An AJAX error occured: " + status +     "
Error: " + error);});

The alert gets called when the problem occurs and the 'status' variable has value of 'error' and the 'error' variable is an empty string...

I really have no idea what could the problem. Some help would be appreciated

</div>
  • 写回答

1条回答 默认 最新

  • weixin_33692284 2012-03-12 20:42
    关注

    Remember to always catch errors and report them so you can find the problem without guessing what it may be:

    $.ajax({
        url : '<url>',
        success : function (serverResponse) { ... },
        error   : function (jqXHR, textStatus, errorThrown) {
            if (typeof console == 'object' && typeof console.log == 'function') {
                console.log(jqXHR);
                console.log(textStatus);
                console.log(errorThrown);
            }
        }
    });
    

    This checks to make sure that console.log exists and is a function before trying to use it. If console.log exists then this will log the all the error information associated with the AJAX request.

    Docs: http://api.jquery.com/jquery.ajax

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?