无效的标签 - jQuery的阿贾克斯/ JSON请求标签、jQuery、JSON、阿贾克斯

2023-09-10 21:43:36 作者:妞丶给爷站住

我一直在拉我的头发了这一点;

I've been pulling my hair out over this;

function status_update( token, loader ){
$("#status-submit").bind( 'click', function(){
    try{
        $("#status-feed-result").html( loader );
        $("#status-input").attr("disabled", "disabled");
        var status_input = $("#status-input").val();
        $.ajax({ 
            type: 'POST', url: './', data: 'token=' + token + '&refresh=true&status-input=' + status_input + '&aj=true', cache: false, timeout: 5000, datatype: 'json',
            error: function(){ $("#status-input").removeAttr('disabled'); }, 
            success: function(html){ 
                auth(html); 
                $("#status-input").removeAttr('disabled'); 
                $("#status-input").val(''); 
                var JSON = eval(html);

                alert(JSON.PROFILE_STATUS); 

                //$(".status-p").html( JSON.PROFILE_STATUS );
                //$(".time").html( JSON.PROFILE_STATUS_TIME );
            }                           
        });
    }catch(err){}
    return false;                                           
});
}

我不断收到错误无效的标签,这是什么意思,我怎么能prevent的发生。任何帮助非常AP preciated。

I keep getting an error invalid label, what does this mean and how can I prevent from happening. Any help much appreciated.

推荐答案

听起来像它可能与此处列出一个jQuery重复AJAX调用错误:的 jQuery的错误#8398

Sounds like it could be related to a jQuery repeat ajax call bug listed here: jQuery Bug #8398

事实证明,jQuery的1.5是修改以后的Ajax调用的JSON来JSONP从而导致这个错误。

It turns out that jQuery 1.5 is modifying subsequent ajax calls for json to jsonp which leads to this error.

我固定它通过遵循错误更改历史所建议的解决方法之一,并把下面的code的地方在我的Ajax调用是由:

I fixed it by following one of the workarounds suggested in the bug change history and placing the following code somewhere before my ajax calls are made:

$.ajaxSetup({
   jsonp: null,
   jsonpCallback: null
});

应该可以解决其他Ajax请求的任何问题了。

Should fix any problems for other ajax requests too.