如何在chrome上调试javascript [英] how to debug javascript on chrome

查看:123
本文介绍了如何在chrome上调试javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个奇怪的问题,jquery.load有时在chrome上失败。我不会打扰你们的细节,我只是在寻找一个指点,我如何调试这样的问题?



我想到了firebug可以帮助,但是问题只发生在chrome上(甚至可以在IE上使用)。



我做了一些事情:

  $(#contentid)。html(Plz wait。); 
$(#contentid)。load(url);
$(#contentid)。show();

我在#contentid上只得到Plz wait,我可以看到url被调用,并手动检查并看到它成功。



更新2:



所以我根据建议更改了负载调用< p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $'$'$' $ url);
if(status ==error)
{
alert(text:+ xhr.statusText);
alert (readyState:+ xhr.readyState +\\\
status:+ xhr.status);
alert(responseText:+ xhr.responseText);
}
else
{
$(#conentid)。show();
}
});

当错误发生时,我得到status =='error'



xhr.statusText:0



xhr.readyState:4



xhr.statusText和xhr.responseText为空



任何想法为什么?这是什么意思?



网址是手动工作的。并且这个错误只发生在chrome上,只有在

解决方案

也许有人可以解释这个答案,但问题是:



我有一个基本href TAG < base href =http://domain.com //>



有一些使用jquery + base href的参考资料。
我不知道为什么,但删除这一行固定一切。感谢所有的帮助,我在这个过程中学到了一些web调试软件提示。


I have this weird issue that jquery.load sometimes fails on chrome. I'm not gonna bother you guys with the details, I'm just looking for a pointing hand on how can i debug such an issue?

I thought of maybe the firebug could help, but the issue happens only on chrome (even works on IE).

I do something like:

$("#contentid").html("Plz wait.");
$("#contentid").load(url);
$("#contentid").show();

I get only the "Plz wait" on #contentid, and i can see the url getting called, and check it manually and see it succeeds.

UPDATE2:

so i changed the load calls according to suggestions

$('#conentid').load(url, function(response, status, xhr){
  alert('Load was performed. url:' + url);
  if (status == "error") 
  {
    alert("text: " + xhr.statusText);
    alert("readyState: "+xhr.readyState+"\nstatus: " + xhr.status);
        alert("responseText: "+xhr.responseText);
  }
  else
  {
      $("#conentid").show(); 
  }
});

I get status=='error' when the errors occur.

xhr.statusText: 0

xhr.readyState: 4

xhr.statusText and xhr.responseText are empty

any idea why? what does this mean?

The url works manually. and this error happens only on chrome, and only sometimes

解决方案

Maybe someone else could have an explanation for this answer, but the problem was:

I had a base href TAG (<base href="http://domain.com/" />)

There are some references for problems with using jquery + base href out there. I have no idea why, but removing this line fixed everything. thanks for all your help, I learned some web debugging\ajax tips in the process.

这篇关于如何在chrome上调试javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆