When I access the following url via browser it works fine returning JSON data,
当我通过浏览器访问以下网址时,它可以正常返回JSON数据,
http://azcvoices.com/topcompanies/wp-content/themes/topcompanies/get.php?p=33
When jquery does an ajax get
it is failing with a 404 Not found error
with the following code even when the file get.php
truly exists on the server as mentioned above,
当jquery执行ajax时,如果上面提到的服务器上的文件get.php确实存在,则使用以下代码失败并发现404 Not found错误,
$.ajax(
{
url: "http://azcvoices.com/topcompanies/wp-content/themes/topcompanies/get.php",
type: "GET",
data: {p: postId}
})
.done(function(post) {
})
.fail(function() { alert("error"); })
.always(function() { });
You may see the 404 error below,
您可能会在下面看到404错误,
Currently the .htaccess has the following in it,
目前.htaccess中有以下内容,
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
Could this be causing the issue?
这会导致这个问题吗?
The same demo on the test server at, http://peplamb.com/workspace/azcentral.com/spotlight-stories/ works fine, but the same code is failing at http://azcvoices.com/topcompanies/spotlight-stories/
测试服务器上的相同演示,http://peplamb.com/workspace/azcentral.com/spotlight-stories/工作正常,但相同的代码在http://azcvoices.com/topcompanies/spotlight-stories失败/
What could be the issue? Any help is greatly appreciated!
可能是什么问题?任何帮助是极大的赞赏!
1 个解决方案
#1
6
Are you making the request from the same domain as the page is hosted on? If not, you might be running into a problem with Cross-Origin Resource Sharing.
您是否在托管页面的同一域中发出请求?如果没有,您可能会遇到跨源资源共享问题。
To fix this, you might be able to add Access-Control-Allow-Origin: *
as a header.
要解决此问题,您可以将Access-Control-Allow-Origin:*添加为标题。
#1
6
Are you making the request from the same domain as the page is hosted on? If not, you might be running into a problem with Cross-Origin Resource Sharing.
您是否在托管页面的同一域中发出请求?如果没有,您可能会遇到跨源资源共享问题。
To fix this, you might be able to add Access-Control-Allow-Origin: *
as a header.
要解决此问题,您可以将Access-Control-Allow-Origin:*添加为标题。