简体   繁体   English

Ajax-XHR 加载失败,内部服务器错误 500

[英]Ajax- XHR failed loading with internal server error 500

I have a method delete ajax call to remove a field from table, but on click my console shows this error我有一个方法 delete ajax 调用从表中删除一个字段,但单击我的控制台显示此错误

and i get same error for my another post method ajax.我的另一个 post 方法 ajax 也出现了同样的错误。 And both works perfectly on my localhost and not on server.两者都在我的本地主机上完美运行,而不是在服务器上。 this is my ajax code,这是我的ajax代码,

    function delSubTask(sid,id){
    var place = 'sub-'+sid;
    var badge = 'badge-'+id;
    var count = document.getElementById(badge).innerHTML;
    count--;
    $.ajax({
        type: "DELETE",
        url: "/myurl/"+sid,
        data: {id:id},
        success: function(data) {
            console.log(data);
            var e = document.getElementById(place);
            $(e).fadeOut( "slow", function() {
                // After animation completed:
                $(e).remove();
            });
            document.getElementById(badge).innerHTML=count;
        },
        error: function(){
            alert('Failed to delete #errsub25');
            $('input:checkbox').removeAttr('checked');
        }
    });
}

It is hard to say because there are many reasons to cause HTTP 500 internal error.很难说,因为导致HTTP 500内部错误的原因有很多。 Mostly, it about your service on the server.大多数情况下,它与您在服务器上的服务有关。

In my experience, it might because of CORS (more explanation here https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS ) because moving from localhost to actual server usually has this problem.根据我的经验,这可能是因为 CORS(这里有更多解释https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS ),因为从 localhost 移动到实际服务器通常会出现这个问题。

Or you might give more information about what is the response (or debug by yourself).或者您可以提供有关响应是什么的更多信息(或自己调试)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM