This scripts works fine when running from visual studio, but does not work on iis. It does not return data and fails
error: function (xhr) {alert('error');}
could it be the url format? do I need to add @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>
use @Url.Action(..) in all your urls. It should work in both visual studio and when published to iis
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.