简体   繁体   English

找不到AJAX网址,因为Web服务器托管为IIS上另一个网站的子应用程序

[英]AJAX url not found because the web server is hosted as an sub app of another website on IIS

I need to send an AJAX request, and the program is ok when I run it at my pc. 我需要发送一个AJAX请求,并且在我的PC上运行该程序时,程序正常。

$.post("/coupon/sync"/, .....)

Chrome develpment tools shows that the request url is localhost:8373/coupon/aync Chrome开发工具显示请求网址为localhost:8373/coupon/aync

But when I publish the website into server, which hosts like: 但是,当我将网站发布到服务器时,其主机如下:

在此处输入图片说明

( pm is the website I published) pm是我发布的网站)

The correct request url should be www.xxx.com/pm/coupon/aync , but the actual url is www.xxx.com/coupon/aync (/pm is missing), so the server returns me a 404 not found error. 正确的请求网址应为www.xxx.com/pm/coupon/aync ,但实际的网址为www.xxx.com/coupon/aync丢失),因此服务器向我返回404 not found错误。

Because PM is not a permanent web app name, it may changes to pm2 or something else. 由于PM不是永久的Web应用程序名称,因此它可能会更改为pm2或其他名称。 So I don't want to have the PM set in every ajax url property. 所以我不想在每个ajax url属性中都设置PM Is there a soluthing? 有没有解决办法?

put "~" sign before your path. 在您的路径前加“〜”号。 check below snippet. 检查以下代码段。

$.post("~/coupon/sync"/, .....)

Or 要么

$.post("../coupon/sync"/, .....)

This will work for you. 这将为您工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 托管在另一台服务器上的子域,但可以从URI的URI中重写它 - sub domain hosted on another server but call it from Url Rewrite in iis 7 in domain 一种应用程序,用于获取托管在远程服务器中的网站的IIS和应用程序池详细信息 - An Application which fetches IIS and App Pool details of website hosted in remote server 如何将用户身份从一个IIS中托管的Web应用程序传递到另一个IIS中托管的Web服务? - How to pass on user's identity from web application hosted in one IIS to the web service hosted in another IIS? 将网站托管在MVC / IIS的另一台本地计算机上? - Embed a website hosted on another local machine in MVC/IIS? IIS7托管的网站在服务器上的Iocalhost上运行,但不在本地计算机上 - IIS7 hosted Website working on Iocalhost on server, but not on local computer 使用JavaScript从托管网站重定向到本地IIS服务器页面 - Redirect to Local IIS server page from Hosted website in javascript 如何调试IIS服务器(Godaddy)上托管的ASP.NET网站 - How to debug ASP.NET website hosted on IIS server (Godaddy) Sub Domain就像IIS 7中的Url Rewriting中的网站的子文件夹 - Sub Domain is like Subfolder of website in Url Rewriting in IIS 7 如何在IIS中本地托管的应用程序的URL中添加自定义目录? - How to add custom directory in URL for app hosted locally on IIS? Perfmon / PAL:测量IIS中托管的Web服务器的发送/接收字节 - Perfmon / PAL: Measurement of send/received bytes for a web server hosted in IIS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM