我真的不明白这一点.我有以下'获取'请求:
$.ajax( {
url: "api/getdirectories/",
dataType: 'json',
success: function ( data ) {
// Do stuff
}
} );
Run Code Online (Sandbox Code Playgroud)
这是我的登台服务器提供给我的页面http://atlas/Reporter.在我的本地开发框中,这是有效的,并且在查看提琴手时,我看到了正确的URL http://localhost/Reporter/api/getdirectories.然而,在登台服务器上请求是http://atlas/api/getdirectories,这是无效的,我收到404错误.
为什么我的路径中的'Reporter'部分被丢弃在登台服务器上?在查看文档时,URL,baseURI,documentURI都是http://atlas/Reporter,域名是atlas.与我的本地开发盒完全相同(除了它是'localhost'而不是'atlas'.
这个问题困扰了我一段时间了.我想我已经弄明白了,一切都很好,然后再次遇到它.我不认为这是一个相同的原始政策问题,因为我要求页面来自同一网站的数据.
那么,为请求确定的完整网址究竟是如何确定的?它似乎不是上面提到的文档变量之一连接到我的相对URL ...所以这是如何工作的?
Edit: Removed the '/' from the URL as it is distracting from the real issue- behavior is the same with or without it.