本文介绍了jQuery的$。员额工作有时有时会返回403 Forbidden错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候,我得到一个403 Forbidden错误,我看不出有什么不对。
这是我的jQuery code:

Sometimes I get a 403 forbidden error, I can't see what's wrong.
Here is my jQuery code:

    $.ajax({
        type: 'POST',
        url: './ajax-conf-editc.php',
        data: { conf_id: Id, conf_contenido: data },
        async: false,
        success: function(msg){
            if ( msg == '1' || msg == 1){
                var confname = $('#nameConf').val();
                $.cookie('SUCCESS', 'Se ha guardado el contenido de la configuración "' + confname + '".', { expires : 1, path : '/' });
                $(window.location).attr('href', 'index.php');
            } else {
                $('#conf-editc-form').removeAlertBoxes();
                $('#conf-editc-form').alertBox(msg, {type: 'error'});
            }
        }
    });

通过这些数据做工精细:

With this data work fine:

conf_id=11&conf_contenido=%2523tabs-0%253CtabContent%253E%253Cp%253EContenido%253C%2Fp%253E%253CtabTitle

但是,当我发这个,失败并返回我禁止的403

But when I send this, fail and return me an 403 Forbidden

conf_id=11&conf_contenido=%2523tabs-0%253CtabContent%253E%253Cp%253E%253Ca%2520onclick%253D%2522javascript%253A%2524%2528%2520%2527%2523tabs%2527%2520%2529.tabs%2528%257Bselected%253A1%257D%2529%253Bscroll%25280%252C0%2529%2522%2520href%253D%2522javascript%253Avoid%25280%2529%253B%2522%253EContenido%253C%2Fa%253E%253C%2Fp%253E%253CtabTitle%253EInicio%253Ctabs%253E%2523tabs-1%253CtabContent%253E%253Cp%253EContenido%25201%253C%2Fp%253E%253CtabTitle%253Edos

我希望有人能帮助我,告诉我为什么是这样呢?

I hope someone can help me and can tell me why is this happen?

这是我得到的消息时失败:

this is the message i get when fail:

禁止

您没有权限访问/kidspc2/configuraciones/ajax-conf-editc.php此服务器上。

You don't have permission to access /kidspc2/configuraciones/ajax-conf-editc.php on this server.

此外,一个404 Not Found错误,而试图使用ErrorDocument来处理请求时遇到。

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

编辑:可能是mod_security的这样做呢?怎么我不能查吗?

Could be mod_security doing this? how can't i check it?

编辑:我解决这个问题,为Base64 enconding conf_content值

i resolve this, enconding conf_content value in Base64.

推荐答案

我猜你的$就要求超过一次的时间很短的时间,这就是为什么您收到此404错误。您可以通过取消所有的previous Ajax调用解决这个问题,并作出新的Ajax调用了最新的Ajax调用请求。希望这可以帮助。

I guess your $.ajax is requested more than once in a very short interval of time that is why you are getting this 404 error.you can fix it by canceling all the previous ajax call and make a new ajax call for latest ajax call request. Hope this helps.

就像跌破code:

    if( this.ajax ){
            this.ajax.abort();
        }
        this.ajax=$.ajax({
        type: 'POST',
        url: './ajax-conf-editc.php',
        data: { conf_id: Id, conf_contenido: data },
        async: false,
        success: function(msg){
        if ( msg == '1' || msg == 1){
            var confname = $('#nameConf').val();
            $.cookie('SUCCESS', 'Se ha guardado el contenido de la configuración "' + confname +        '".', { expires : 1, path : '/' });
            $(window.location).attr('href', 'index.php');
        } else {
            $('#conf-editc-form').removeAlertBoxes();
            $('#conf-editc-form').alertBox(msg, {type: 'error'});
        }
    }
});

这篇关于jQuery的$。员额工作有时有时会返回403 Forbidden错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 22:34