Ajax调用不断从控制器MVC ASP.net返回错误

时间:2018-12-26 10:11:04

标签: javascript jquery asp.net ajax asp.net-ajax

Onclick事件,我正在向Home Controller发送一个ajax调用。它不断返回错误。

var appraiserform = {
            FormNumber: $('#formnumber').text(),
            FileDetails:
            {
                FormNumber: $('#formnumber').text(), ReferenceNumber: $('#RefrenceNumber').text(), RequiredBy: $('#RequiredBy').text(), ReportLanguage: $('#ReportLanguage').text(),
                SubjectProperty: $('#SubjectProperty').text(), ReportType: $('#ReportType').text(), /*ApplicantName: $('#ApplicantName').text(),*/
                AdditionalServices: $('#AdditionalServices').text(), AppraisalType: $('#AppraisalType').text()
            },
            SubjectProperty:
            {
                Source: $('#Source').val(), MunicipalityorDistrict: $('#MunicipalityDistrictSP').val(), LegalDescription: $('#LegalDescriptiontxtSP').val(),
                OccupiedBy: {
                    SelectedItem: $('#OccupiedBySP').val(),
                    Note: ""
                },
                Address: {
                    StreetAddress1: $('#StreetAddress1SP').val(),
                    StreetAddress2: $('#StreetAddress2').val(),
                    City: $('#citySP').val(),
                    Province: $('#ProvinceSP').val(),
                    PostalCode: $('#PostalCodeSP').val()
                },
                Assessment: {
                    Land: $('#Aland').val(),
                    Improvements: $('#Improvement').val(),
                    Total: $('#Total').val(),
                    Taxes: $('#Taxes').val(),
                    Year: $('#Year').val(),
                    AssesmentData: $('#AssesmentData').val()
                },
                ExistingUse: {
                    SelectedItem: $('#ExitingUseSP').val(),
                    Note: ""
                }
            }
        }
        $.ajax({
            type: 'POST',
            dataType: 'json',
            url: 'AppraisalFormsWeb/Home/FormSubmit',
            data: {
                appraiserform: appraiserform,
            },
            success: function (data) {
                var dt = new Date();
                var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
                //alert("success" + data);
                console.log('console success')
                $('#lasttimesave').text(time);

            },
        error: function (data) {
            alert("error" + data);
            console.log(data);
            var dt = new Date();
            var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
            //alert("success" + data);
            $('#lasttimesave').text("Last saved " + time);

        }
    });

0 个答案:

没有答案