cg91 cg91 - 1 month ago 29
Ajax Question

Javascript not working after publish to IIS

I have searched on the internet for a while now to try and find something similar to help me without succes.

The code I have written below works perfectly on my local host but not on the server, can anyone please offer some advice, happy to add any extra code if required.

$(function() {
$("#SelectedStillage").on("change", function() {
var orderid = '@ViewBag.SalesOrder';
var stillageid = $(this).val();
$.ajax({
type: "GET",
url: "/DespatchPrintLabels/_itemsPackedInStillage",
data: {
orderID: orderid,
stillageID: $(this).val()
},
success: function(data) {
$("#target").html(data);
},
error: function() {
alert("Something went wrong ");
}
});
});
})

Answer

Use

url: '@Url.Action("_itemsPackedInStillage" "DespatchPrintLabels")'