如何在chrome上调试javascript [英] how to debug javascript on 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屋!