No 'Access-Control-Allow-Origin' header is present on the requested resource.
I am working on an app running on port 7070. Here I want to implement ajax post to the file in my root directory(www/html). So the code I was wrote is as follows. Ajax post
$.ajax({
type: "POST",
crossDomain: true,
data: {patient_id : data},
url: "url", //http://ipaddress/test/php/filename.php
success: function(data){
if(isJson(data))
{
// do something
}
}
});
My php file is as follows. Php is located at " www/html/php "
<?php
$pat_id = $_POST['patient_id'];
echo "something";
?>
This is returning me an error like this in my chrome console.
XMLHttpRequest cannot load ipaddress/test/php/filename.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'ipaddress:7070' is therefore not allowed access.
But when I attempt the same request from my root directory(by doing ajax post from a file in root directory) it worked.
I tried adding " dataType : jsonp " that doesnt work.