Tomer Aro Tomer Aro - 3 months ago 16
Ajax Question

Ajax url local VS production

I build webpage including few ajax functions, for example:

$.get('/Home/FutureRequestDialog', { FutureRequestID: futureReqID }, function (data) {
$('#PopUpData').html(data);
$("#edit_request_pop").modal('show');
});


When i'm running it in localhost the action "FutureRequestDialog" fired as expected.
When i'm upload the webpage to production server, for example in the url - www.***.com/client - The ajax function don't find the url.
and i'm getting this error:

GET http://www.***.com/Home/FutureRequestDialog?FutureRequestID=15 404 (Not Found)


and it's true. the get url must be to the address: http://www.***.com/client/Home/RequestDialog?RequestID=15

I don't want to edit the get url every time i want to debug my project in local and production. My project is ASP.net MVC.
Do you have any ideas?

Answer

Try following

$.get('@Url.Action("FutureRequestDialog", "Home")', { FutureRequestID: futureReqID }, function (data) {
        $('#PopUpData').html(data);
        $("#edit_request_pop").modal('show');
    });
Comments