Why is jQuery ajax get returning a 404 Not found error even while the file exists on the server?

.htaccess, http-status-code-404, javascript, jquery

Solution

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.

Problem

When I access the following url via browser it works fine returning JSON data, 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, ``` $.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, 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? 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/ What could be the issue? Any help is greatly appreciated!

Original source