Firefox 5 中的 Ajax 请求可在 Webkit 中运行
这是我尝试过的第一个简单的 javascript ajax 请求,但没有成功。
var obj = {};
obj.action = "clubbar";
$.post("/ajax/lojack", obj, function(data){
var real = JSON.parse(data);
});
当我执行 json 解析函数时,我收到此错误
uncaught exception: [Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://localhost:8888//admin/newclubbar.jsp :: <TOP_LEVEL> :: line 381" data: no]
当我尝试在没有 jquery 的情况下执行此操作时,我收到相同的错误:
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var data = JSON.parse(xmlhttp.responseText);
}
}
xmlhttp.open("GET","/ajax/lojack?action=clubbar",true);
xmlhttp.setRequestHeader("Content-type", "text/html");
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(null); I also tried xml.http.send("");
我可以发布实际的 JSON,但 Webkit 没有问题
Here is the first simple javascript ajax request that I tried that did not work.
var obj = {};
obj.action = "clubbar";
$.post("/ajax/lojack", obj, function(data){
var real = JSON.parse(data);
});
When I do the json parse function i get this error
uncaught exception: [Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://localhost:8888//admin/newclubbar.jsp :: <TOP_LEVEL> :: line 381" data: no]
When I tried to do it without jquery, I get the same error:
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var data = JSON.parse(xmlhttp.responseText);
}
}
xmlhttp.open("GET","/ajax/lojack?action=clubbar",true);
xmlhttp.setRequestHeader("Content-type", "text/html");
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(null); I also tried xml.http.send("");
I could post the actual JSON but Webkit has no problem with it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)