[英]Ajax url local VS production
I build webpage including few ajax functions, for example: 我建立的网页包含一些ajax函数,例如:
$.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. 当我在localhost中运行它时,动作“ FutureRequestDialog”按预期触发。 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.
当我将网页上传到生产服务器时,例如在URL-www。***。com / client中-Ajax函数找不到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
获取网址必须是以下地址: 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. 我不想每次在本地和生产环境中调试项目时都编辑get url。 My project is ASP.net MVC.
我的项目是ASP.net MVC。 Do you have any ideas?
你有什么想法?
Try following 尝试跟随
$.get('@Url.Action("FutureRequestDialog", "Home")', { FutureRequestID: futureReqID }, function (data) {
$('#PopUpData').html(data);
$("#edit_request_pop").modal('show');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.