im trying to access my localhost i.e. localhost/app and trying to get back some data back in json, this is the php script
<?php
header('Access-Control-Allow-Origin: *');
//test if a post request came
if(isset($_POST)) {
//return a json request
$contactDetails = array(
"email" => "some@some.com",
"twitter" => "@example",
);
echo json_encode($contactDetails);
}
?>
this php file is located at index.php
im trying to access this page using localhost/app page but im getting 301 error in firebug, i dont know why, any help appreciated
IT WORKS ON THE WEB BROWSER, but not when i try to request the information from somehere else
You’re trying to access a localhost URL from an external (i.e. a live) website? That website would have no way of accessing your localhost unless you’ve given it a public IP, which I’m assuming you haven’t.