且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET MVC 4 jQuery Ajax请求返回内部服务器错误

更新时间:2022-04-23 08:51:10

ajax请求抛出无效的JSON原语异常.因此,使用 JSON.stringify(obj)

The ajax request throws Invalid JSON primitive exception. So Pass the data using JSON.stringify(obj)

Ajax请求

    var prm = $("#prods").val();
    var obj = { prodID: prm };
    $.ajax({
        type: "POST",
        url: '@Url.Action("FilterCategeory", "Home")',
        contentType: "application/json; charset=utf-8",
        data : JSON.stringify(obj),
        dataType: "json",
        success: function (data) {
            alert('Success');
        },
        error: function () { alert('error'); }
    });

选中此问题希望对您有所帮助.

您可以在Firefox或Chrome中检查错误类型 在Firefox中

You can check the error type in Firefox or Chrome In firefox

右键单击浏览器,然后单击检查元素.然后选择网络 标签.当您单击请求时,它将显示标题,Cookie等.从中选择响应".这样您就可以找到错误

Right click the browser click Inspect Element. Then selected the Network tab. When you click the request it will show header, cookies etc. From that choose Response. So you can found the error

镀铬