Tomer Aro Tomer Aro - 1 year ago 95
Ajax Question

Ajax url local VS production

I build webpage including few ajax functions, for example:

$.get('/Home/FutureRequestDialog', { FutureRequestID: futureReqID }, function (data) {

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 MVC.
Do you have any ideas?

Answer Source

Try following

$.get('@Url.Action("FutureRequestDialog", "Home")', { FutureRequestID: futureReqID }, function (data) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download