这段代码有什么错误?我的数据未插入sql服务器

时间:2019-04-08 10:59:21

标签: json ajax asp.net-mvc asp.net-ajax

我已经通过邮递员检查了我的api及其工作原理,但是错误出在jquery或ajax中。

我试图找到错误,但无法理解。请尝试解决此问题。非常感谢

       $(document).ready(function () {

        $("#AddPatientReport").click(function () {
            alert("PatientReport Added Successfully");

            var DoctorId = $("#ReportDoctorId").val();
            var DoctorName = $("#ReportDoctorName").val();
            var PatientName = $("#ReportPatientName").val();
            var PatientId = $("#ReportPatientId").val();
            var PharmacyCategory1 = $("#ReportPharmacyCategory1").val();
            var Medicine1 = $("#ReportMedicine1").val();
            var PharmacyCategory2 = $("#ReportPharmacyCategory2").val();
            var Medicine2 = $("#ReportMedicine2").val();
            var AppointmentDate = $("#ReportPatientDate").val();
            var AppointmentTime = $("#ReportPatientTime").val();
            var PatientDescription = $("#ReportPatientDescription").val();

            $.ajax({

                url: '/home/addpatientreport',
                type: 'POST',
                data: {
                    DoctorId: DoctorId,
                    DoctorName: DoctorName,
                    PatientName: PatientName,
                    PatientId: PatientId,
                    PharmacyCategory1: PharmacyCategory1,
                    Medicine1: Medicine1,
                    PharmacyCategory2: PharmacyCategory2,
                    Medicine2: Medicine2,
                    AppointmentDate: AppointmentDate,
                    AppointmentTime: AppointmentTime,
                    PatientDescription: PatientDescription
                },
                dataType: 'application/json; charset=utf-8',
                contentType: "application/x-www-form-urlencoded"

            });
        });
    });

0 个答案:

没有答案