使ajax调用无法在iis上工作的jQuery脚本
此脚本在从visual studio运行时工作正常,但在iis上不工作。它不返回数据并且失败使ajax调用无法在iis上工作的jQuery脚本,jquery,asp.net,ajax,asp.net-mvc-4,asp.net-mvc-5,Jquery,Asp.net,Ajax,Asp.net Mvc 4,Asp.net Mvc 5,此脚本在从visual studio运行时工作正常,但在iis上不工作。它不返回数据并且失败 error: function (xhr) {alert('error');} 可能是url格式吗?我需要添加@url吗 <script> function load() { $.ajax({ url: '/Register/SearchResults', datatype: "json", type: 'GET',
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。。当xhr出现错误时,它实际上包含什么?如果它是web api端点,则可能缺少控制器之前的/api/,或者它无法找到路由。请检查。格式可能错误url:“@url.actionbnform,Register?id'+$”输入[name=rbnSR]:选中“Matti,0x800a1391-JavaScript运行时错误:“id”未定义**********在Visual Studio中工作正常。在IIS中运行时它不工作*********