Ajax call results in 500 Internal Server Error

◇◆丶佛笑我妖孽 提交于 2019-12-12 02:05:44

问题


I have read similar posts and Modified according to them ..still not able to fix this error on My Page .. On Debug ..In FireBug there is no other error shown in Console ..Just this Error

500 Internal Server Error

....parameters Name in method is also same

this is my ajax method :

function getErrorStatusList() {
    var serve = new Object();
    serve.issueID = $("#proselct option:selected").val();
    $.ajax({
        type: "POST",
        url: "UFZillaErrorStatus.aspx/GetErrorStatusList",
        data: JSON.stringify(serve),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {

        },
        error: function () { alert("Server Error!!");}

    });

this is WebMethod

 public partial class UFZillaErrorStatus : System.Web.UI.Page
    {

        [WebMethod]
        public static UFZillaErrorStatusList GetErrorStatusList(int issueID)
        {
            return Dashboard.Model.UFZillaErrorStatus.UFZillaErrorStatusService.Get(issueID);
        }
}

what Else could be done to track this issue ..Any Suggestion would be Helpful


回答1:


Can you please try as below:

 function getErrorStatusList() {   
var serve=JSON.stringify({issueID:$("#proselct option:selected").val()});
    $.ajax({
        type: "POST",
        url: "UFZillaErrorStatus.aspx/GetErrorStatusList",
        data: serve,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {

        },
        error: function () { alert("Server Error!!");}

    });



回答2:


I think the problem is with parameter in the service. Your service is written to serve GET method, but you are trying with POST method, sending data in body.

Send data as url parameter as below:

Try the following:

function getErrorStatusList() {
    $.ajax({
        type: "GET",
        url: "UFZillaErrorStatus.aspx/GetErrorStatusList/?issueID="+$("#proselct option:selected").val(),
        dataType: "json",
        success: function (response) {

    },
    error: function () { alert("Server Error!!");}

    });
}

Tell me what output you are getting when you tried this.



来源:https://stackoverflow.com/questions/24241010/ajax-call-results-in-500-internal-server-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!