I am calling an AJAX function in my script from a server of IP - 128.119.30.12:7080 (for example)
Cross Domain: port number are different, so I get error of incompatibility.
$.ajax({
url: "http://128.119.30.12:9000/callback.php",
data: dataObj,
type: "POST",
contentType: 'text/plain',
sucess: function(data,status){
reply = data;
},
error : function(xhr, status, error){
reply = {"error": "Error in fetching data"}
}
}).done(function(reply) {
replyCall(reply);
});
function replyCall(data) {
console.log(data);
}
I have enabled the mod_header function in my Apache server. And setting up header in the called php script - here is the script of php
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
print 'Hellooooooooo Response';
?>
It is still causing errors on chrome - XMLHttpRequest cannot load http://128.119.30.12:9000/callback.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://128.119.30.12:7080' is therefore not allowed access.