簡體   English   中英

Ajax發布請求中的內部服務器錯誤

[英]Internal server error in ajax post request

在此處輸入圖片說明 伙計們,我的ajax發布請求有問題,並且在某些日期不起作用,即它沒有命中控制器,但在某些日期卻可以正常工作,請幫助我找出錯誤,這是我的代碼

$("#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;
});

檢查數據格式。 例如,如果客戶端使用dd / mm / yyyy,而服務器期望使用mm / dd / yyyy,則您將看到HTTP 500錯誤,因為模型綁定程序將無法執行綁定

如下更改您的ajax發布方法。

$.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) {  }
            });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM