Ajax请求不发送错误未知的Firefox错误、Ajax、Firefox

2023-09-10 14:18:30 作者:不爱我就毁了我

在做这个GET同步Ajax请求在Firefox 27.0.1,Fedora的20,jQuery的1.11.0:

  $。阿贾克斯(ajaxParam)。然后(
    函数(r)的{
        HTML = r.html;
    },
    功能(jqXHR){
        的console.log(JSON.stringify([jqXHR,$ .ajaxSettings,ajaxParam],空,4));
    }
);
 

它工作在Chrome 33.0.1750.146为Linux,但在Firefox中没有请求被发送到服务器,它的错误了:

  [
    {
        readyState的:0,
        状态:0,
        状态文本:[异常... \<无消息> \nsresult:\0x805e0006(<未知>)\位置:\JS框架:: http://example.com/static/ jQuery的-1.11.0.min.js :: ::。发送4号线\数据:无]
    },
    {
        URL:http://example.com/pt/BR
        类型:GET,
        isLocal:假的,
        环球:真实,
        过程数据:真实,
        异步:真实,
        的contentType:应用程序/ x-WWW的形式urlen codeD;字符集= UTF-8,
        接受:{
            *:* / *,
            文:text / plain的,
            HTML:text / html的,
            XML:应用程序/ XML,文本/ XML,
            JSON:应用/ JSON,文/ JavaScript的,
            脚本:文/ javascript中,应用程序/ JavaScript的应用/ ECMAScript中,应用程序/ x-的ECMAScript
        },
        内容: {
            XML:{},
            HTML:{},
            JSON:{},
            脚本: {}
        },
        responseFields:{
            XML:responseXML的,
            文:responseText的,
            JSON:responseJSON
        },
        转换器:{
            HTML文本:真实的
        },
        flatOptions:{
            URL:真实,
            背景:真实的
        },
        JSONP:回调,
        缓存:假的,
        传统:真实,
        数据类型:JSON
    },
    {
        URL:/广告/ PT / BR
        数据: {
            realty_id:2
        },
        异步:假的,
        类型:GET
    }
]
 
ajax request payload方式传过去老是报错

借助 nserror 0x805e0006就是NS_ERROR_CONTENT_BLOCKED

回答为 epascarello

这Ajax调用这个函数里面

 函数popupOpen(PARAMS,页面,HTML){
    loadScripts();
    VAR ajaxParam = {
            网址:。/+ page.url +/+ $('#lang_ code')VAL()+'/'+ $('#terr_ code')VAL()
            数据:参数,可以
            异步:假的,
            类型:page.method,
            传统:假的
        },
        realtyId = params.realty_id;
    如果(!HTML){
        $阿贾克斯(ajaxParam)。然后(
            函数(r)的{
                HTML = r.html;
            },
            功能(jqXHR){
                的console.log(jqXHR,$ .ajaxSettings,ajaxParam);
            }
        );
    }
 

和popupOpen是在谷歌地图调用一个点击监听器

  gm.event.addListener(标记[realtyId],'点击',函数(){
    信息窗口[realtyId]。开(地图,标记[realtyId]);
    popupOpen({realty_id:realtyId},realtyId === 0 pageO.modify:pageO.advert?);
});
 

解决方案

由于目标URL有广告世界Adblock Plus的是阻止它。好发生在我身上才去生产。

When doing this GET synchronous ajax request in Firefox 27.0.1, Fedora 20, jQuery 1.11.0:

$.ajax(ajaxParam).then(
    function (r) {
        html = r.html;
    },
    function (jqXHR) {
        console.log(JSON.stringify([jqXHR, $.ajaxSettings, ajaxParam], null, 4));
    }
);

it works in Chrome 33.0.1750.146 for Linux but in Firefox no request is sent to the server and it errors out:

[
    {
        "readyState": 0,
        "status": 0,
        "statusText": "[Exception... \"<no message>\"  nsresult: \"0x805e0006 (<unknown>)\"  location: \"JS frame :: http://example.com/static/jquery-1.11.0.min.js :: .send :: line 4\"  data: no]"
    },
    {
        "url": "http://example.com/pt/BR",
        "type": "GET",
        "isLocal": false,
        "global": true,
        "processData": true,
        "async": true,
        "contentType": "application/x-www-form-urlencoded; charset=UTF-8",
        "accepts": {
            "*": "*/*",
            "text": "text/plain",
            "html": "text/html",
            "xml": "application/xml, text/xml",
            "json": "application/json, text/javascript",
            "script": "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
        },
        "contents": {
            "xml": {},
            "html": {},
            "json": {},
            "script": {}
        },
        "responseFields": {
            "xml": "responseXML",
            "text": "responseText",
            "json": "responseJSON"
        },
        "converters": {
            "text html": true
        },
        "flatOptions": {
            "url": true,
            "context": true
        },
        "jsonp": "callback",
        "cache": false,
        "traditional": true,
        "dataType": "json"
    },
    {
        "url": "/advert/pt/BR",
        "data": {
            "realty_id": "2"
        },
        "async": false,
        "type": "GET"
    }
]

The nserror 0x805e0006 is NS_ERROR_CONTENT_BLOCKED

Answering to epascarello

That ajax call is inside this function

function popupOpen(params, page, html) {
    loadScripts();
    var ajaxParam = {
            url: '/' + page.url + '/' + $('#lang_code').val() + '/' + $('#terr_code').val(),
            data: params,
            async: false,
            type: page.method,
            traditional: false
        },
        realtyId = params.realty_id;
    if (!html) {
        $.ajax(ajaxParam).then(
            function (r) {
                html = r.html;
            },
            function (jqXHR) {
                console.log(jqXHR, $.ajaxSettings, ajaxParam);
            }
        );
    }

and popupOpen is called by a click listener in a Google map

gm.event.addListener(marker[realtyId], 'click', function () {
    infoWindow[realtyId].open(map, marker[realtyId]);
    popupOpen({ realty_id: realtyId }, realtyId === 0 ? pageO.modify : pageO.advert);
});

解决方案

Since the target url had the advert world Adblock Plus was blocking it. Good it happened to me before going in production.