火狐ajax调用返回NS_ERROR_DOM_BAD_URI或jsonp错误的错误 [英] firefox ajax call returning NS_ERROR_DOM_BAD_URI or jsonp false error

查看:162
本文介绍了火狐ajax调用返回NS_ERROR_DOM_BAD_URI或jsonp错误的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于不能在Firefox中调试悬挂$ .post扩展名



任何人都可以告诉我为什么我的扩展名 https://builder.addons.mozilla.org/addon/1022928/latest/ 是用这个ajax调用的:

  var url ='http://e-ønsker.dk/wishlist/ajax/add/'; 
$(this).hide();
//显示图标加载
$(#icon)。show(); $ b $ .ajax({
type:POST,
url:url,
data:{title:$(#txtTitle)。val(),url: encodeURIComponent(taburl)},
success:function(data,textStatus){$ b $ if(data.code> 0)
{
$(#icon)。removeClass ().addClass('accept');
}
else
{
$(#icon)。removeClass()。addClass('error');
if(data.code =='-1')
alert('kunne ikke finde dinønskeseddelpåe-ønsker.dk - besøge-ønsker.dkand ogprøvderefter igen');


错误:function(data,textStatus){
alert(textStatus);
$(#icon)。removeClass()。addClass('error ');
}
});

正在返回错误NS_ERROR_DOM_BAD_URI。 HttpFox表示,这是一个500错误,这将表明一个内部错误,但这个确切的调用在扩展中的铬和safari的工作,所以我怀疑错误是专门与Firefox相关的。


$因此,我添加了 dataType:jsonp

UPDATE 这样做的一些神奇,现在我得到了200响应,但我仍然得到一个parsererror。

最奇怪的是,我修改我的服务器,以适应JSONP jQuery选择了错误的方法,我在这里显示的xhr.statusText alert(xhr.statusText); 给了我一个警告statustext成功为什么不会jquery选择成功的方法,当它实际工作??

解决方案

您不能从您正在使用的不同的域中获取数据AJAX - > http://en.wikipedia.org/wiki/Same_origin_policy



如果您使用的是相同的域,那么使用相对路径...我怀疑Firefox是对url的 e-ønsker.dk部分进行编码 - 使它看起来像一个不同的域。


In relation to can't debug hanging $.post in firefox extension

can anyone tell me why my extension https://builder.addons.mozilla.org/addon/1022928/latest/ is with this ajax call:

var url = 'http://e-ønsker.dk/wishlist/ajax/add/';
$(this).hide();
//show icon loading
$("#icon").show();
$.ajax({
  type: "POST",
  url: url,
  data: {title:$("#txtTitle").val(), url:encodeURIComponent(taburl)},
  success: function(data, textStatus) {
        if(data.code > 0)
    {
    $("#icon").removeClass().addClass('accept');
    }
    else
    {
    $("#icon").removeClass().addClass('error');
    if(data.code == '-1')
        alert('kunne ikke finde din ønskeseddel på e-ønsker.dk - besøg e-ønsker.dk, og prøv derefter igen');
    }
  },
  error: function(data, textStatus) {
      alert(textStatus);
    $("#icon").removeClass().addClass('error');
  }
});

is returning the error NS_ERROR_DOM_BAD_URI. HttpFox says it's a 500 error which would indicate an internal error, but this exact call works from both chrome and safari in their extensions, so I'm suspecting the error to be related to firefox specifically.

UPDATE

So I added dataType: "jsonp" and that did some of the magic, now I get a 200 response, but I still get a parsererror.

Weirdest thing is that after I modify my server to accomodate JSONP jquery chooses the error method, and the xhr.statusText that I show here alert(xhr.statusText); gives me an alert with the statustext "success" why won't jquery choose the success method when it actually works??

解决方案

You cannot get data from a different domain from the one you are currently on using AJAX -> http://en.wikipedia.org/wiki/Same_origin_policy

If you are using the same domain then use relative paths ... I suspect that Firefox is encoding the e-ønsker.dk part of the url - making it look like a different domain.

这篇关于火狐ajax调用返回NS_ERROR_DOM_BAD_URI或jsonp错误的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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