繁体   English   中英

jQuery 使 ajax 调用无法在 iis 上运行的脚本

[英]jQuery script that makes ajax call not working on iis

从 visual studio 运行时,此脚本工作正常,但不适用于 iis。它不返回数据并失败

error: function (xhr) {alert('error');}

可能是 url 格式吗? 我需要添加@url吗

<script>
function load() {
    $.ajax({
        url: '/Register/SearchResults',
        datatype: "json",
        type: 'GET',
        contentType: 'application/json',
        data: { npi: $("#NPI").val(), first: $("#First").val(), last: $("#Last").val() },
        async: true,
        processData: true,
        cache: false,
        success: function (data) {
            $("#SearchResults").empty();
            $("#SearchResults").append('<table class="table" id="records_table"><tr><th></th><th>DEA#</th><th>Life#</th><th>NPI #</th>' +
               '<th>NYS License</th><th>License Type</th><th>First Name</th>' +
               '<th>Last Name</th></tr></table>');

            for (var i = 0; i < data.length; i++) {
                $("#records_table").append('<tr id="' + data[i].NPI + '" ><td><input id="chk_' + data[i].NPI + '"  value="' + data[i].NPI + '" name="rbnSR" type="radio"></td><td>' +
                   data[i].DEA + '</td><td>' +
                   data[i].Life_Hosp + '</td><td>' +
                   data[i].NPI + '</td><td>' +
                   data[i].LIC + '</td><td>' +
                   data[i].License_Type + '</td><td>' +
                   data[i].FirstName + '</td><td>' +
                   data[i].LastName + '</td></tr>'
                   )
            }
            $("#btnSubmitBNForm").show();
        },
        error: function (xhr) {
            alert('error');
        }
    });
}

$("#btnSubmit").click(function (evt) {
    $("#searchFormError").hide();
    if ($("#NPI").val().trim() != "") {
        load();
    }
    else if ($("#First").val().trim() != "" || $("#Last").val().trim() != "") {
        load();
    }
    else {
        $("#searchFormError").show();
    }
});

$("#btnSubmitBNForm").click(function () {
    if ($('input[name="rbnSR"]:checked').length != 0) {
        $.ajax({
            url: '/Register/BNEForm?id=' + $('input[name="rbnSR"]:checked').val(),
            datatype: "json",
            type: 'POST',
            contentType: 'application/json',
            data: {},
            async: true,
            processData: true,
            cache: false,
            success: function (data) {
                if (data != "false") {
                    location.href = '@Url.Action("IdProofing", "Register")/' + data;
                }
            },
            error: function (xhr) {
                alert('error');
            }
        });
    }
    else {
        alert("Plase select a value from table");
    }
});

$("body").on("click", "#records_table tr", function () {
    $("input[type=radio]").prop('checked', false);
    $("#records_table tr").removeClass("success");
    $(this).addClass("success");
    $("#chk_" + $(this).attr("id")).prop('checked', true);
});


</script>

在所有网址中使用 @Url.Action(..) 。 它应该在视觉工作室和发布到 iis 时都有效

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM