i_user
i_user

Reputation: 513

Accessing remote data with .htaccess

I'm developing an app with php and html5 and I want to access some data from my remote server via ajax. I read from the web and learnt I had to include .htaccess at the root level of my remote server which I've done that but when I try to access from info it gives me this error:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 404.

I'm using chrome for debugging the app.

This is how my files look:

.htaccess

# <IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
# </IfModule>

ajax

$(document).ready(function () {

$('#read').load('http://mywebsite/appsfolder/sample.php');

});

Upvotes: 2

Views: 263

Answers (1)

enkrates
enkrates

Reputation: 626

As Samurai8 mentioned in a comment, uncomment (that is, remove the '#' from the beginning of each line) the part of your .htaccess file that you posted. Your server will only send the header when that block is uncommented.

Upvotes: 2

Related Questions