为什么即使文件存在于服务器上的jQuery AJAX得到返回404未找​​到错误? [英] Why is jQuery ajax get returning a 404 Not found error even while the file exists on the server?

查看:223
本文介绍了为什么即使文件存在于服务器上的jQuery AJAX得到返回404未找​​到错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我通过浏览器访问以下网址,它工作正常返回JSON数据,

When I access the following url via browser it works fine returning JSON data,

http://azcvoices.com/topcompanies/可湿性粉剂内容/主题/ topcompanies / get.php?P = 33

在jQuery不会一个Ajax GET 这是没有用 404未发现错误具有以下$ C $ Ç即使该文件时 get.php 真正存在于服务器上如上所述,

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,

$.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() {  });

您可能会看到下面的404错误,

You may see the 404 error below,

目前的.htaccess有以下的话,

Currently the .htaccess has the following in it,

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?

在测试服务器上对同一演示, http://peplamb.com/workspace/azcentral.com/spotlight-stories/ 做工精细,但同样的code未能在 http://azcvoices.com/topcompanies/spotlight -stories /

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/

可能是什么问题?任何帮助是极大AP preciated!

What could be the issue? Any help is greatly appreciated!

推荐答案

您实现从同一个域的要求在页面上承载?如果没有,你可能正在运行与<一有问题href="http://techblog.constantcontact.com/software-development/using-cors-for-cross-domain-ajax-requests/">Cross-Origin资源共享。

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.

这篇关于为什么即使文件存在于服务器上的jQuery AJAX得到返回404未找​​到错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆