无法加载服务器响应的资源状态为500(内部服务器错误)webmethod

时间:2018-05-08 12:43:33

标签: javascript c# asp.net webmethod morris.js

我在网页中调用Web方法将数据绑定到morris图表,但面临未找到的问题资源。错误是:

  

无法加载服务器响应的资源,状态为500(内部服务器错误)

我还设置了断点来检查是否调用了web方法,但调试器从未达到过这一点。

function Graph() {
        var data = "";
        debugger;
        $.ajax({
            type: "GET",
            url: '<%=ResolveUrl("~/MainMenuB.aspx/ProcessRequestNew") %>',
            dataType: 'json',                
            contentType: "application/json; charset=utf-8",
            data: {},

            success: function (response) {
                debugger;
                data = response;
            },
            error: function (xhr, status, error) {
                debugger;
                alert(error);
            }
        });

        debugger;
        return data;
    }

的webmethod

[System.Web.Services.WebMethod]
public static string ProcessRequestNew()

{
    List<GraphData> dataList = new List<GraphData>();

    SqlConnection connM = new SqlConnection(connstr);

    string chartName = "line";
    string data = string.Empty;

    GraphData graphData = null;        

    if (!string.IsNullOrEmpty(chartName))
    {
        SqlCommand cmd = new SqlCommand();
        if (connM.State == ConnectionState.Closed)
        {
            connM.Open();
        }
        cmd.Connection = connM;
        cmd.CommandText = "SPR_FE_Dashboard";
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@Flag", "NewB");
        cmd.Parameters.AddWithValue("@SP_Flag", "INQ");

        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(ds);
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            GraphData details = new GraphData();
            graphData.label = Convert.ToString(ds.Tables[0].Rows[i]["WK"].ToString());
            graphData.value = Convert.ToString(ds.Tables[0].Rows[i]["Quantity"].ToString());               
            dataList.Add(details);
        }
    }


    data = JsonConvert.SerializeObject(dataList);
    return data;


}

0 个答案:

没有答案