ajax post请求中的内部服务器错误

时间:2014-03-18 06:22:00

标签: c# jquery ajax asp.net-mvc

enter image description here伙计们我的ajax邮件请求有问题但它在某些日期没有工作,但它没有达到控制器但是在某些日期它工作正常请帮我查找bug 这是我的代码

$("#getInfo").click(function ()
{
    var elementValue = document.getElementById("tournamentID").value;
    var startDateValue = document.getElementById("filterDateStartnew").value;
    if (elementValue == null || elementValue == "" || startDateValue == null || startDateValue == "")
        {
            alert("please enter TournamentID and timestamp to get Info");
            return false;
        }
    $.ajax({
        type: "POST",
        cache: false,
        url: '/reports/gettournamentinfo',
        data: { tournamentID: elementValue,date: startDateValue },
        success: function (data)
        {
            var select = document.getElementById("TournamentLevel");
            var length = select.options.length;
            //Delete All Options
            $('#TournamentLevel')
                .find('option')
                .remove()
                .end()
            var opt = document.createElement("option");
            opt.text = "Any";
            opt.value = -1;
            document.getElementById("TournamentLevel").options.add(opt);
            var count = data[0];
            for (var i = 1; i <= count; i++)
            {
                var opt = document.createElement("option");
                opt.text = i;
                opt.value = i;
                document.getElementById("TournamentLevel").options.add(opt);
            }

            for (var index = 1; index < data.length; ++index)
            {
                var opt = document.createElement("option");
                opt.text = data[index];
                opt.value = data[index];
                document.getElementById("RunID").options.add(opt);
            }
            $("#SubmitForm").removeAttr('disabled');
        },
        error: function(data)
        {
            alert("there was no info for that tournamentID and that date");
            $.unblockUI();
            $('#TournamentLevel')
.find('option')
.remove()
.end()
            return false;
        }
    });

        return false;
});

2 个答案:

答案 0 :(得分:1)

检查数据格式。例如,如果客户端使用dd / mm / yyyy并且服务器期望mm / dd / yyyy,您将看到HTTP 500错误,因为模型绑定器将无法执行绑定

答案 1 :(得分:0)

更改您的ajax post方法,如下所示。

$.ajax({ url: "/reports/gettournamentinfo", contentType: "application/json; charset=utf-8", type: "POST",
                data: '{"tournamentID":"' + elementValue+ '", "date":"' + startDateValue + '"}',
                success: function (data) {      
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {  }
            });