I'm dealing with a problem the whole week already and can't find the answer anywhere.
This is the problem:
XMLHttpRequest cannot load http://www.websiteA.com/process.php. Origin http://clientwebsi.te is not allowed by Access-Control-Allow-Origin.
I have a Javascript file that is located at the server from website A. Clients can load the JS file on there website.
On the server A is also a process.php located that puts information in the database on server A.
I'm using now this code:
var dataText = 'page=' + top.location.host;
$.ajax({
type: "POST",
url: "process.php",
data: dataText,
error: function(request,error){
alert(error);
},
success: function(request) {
alert(request.length);
}
});
This code works perfectly on localhost but not when i'm using the server A and client server (cross domain)
This is the online code:
$.ajax({
type: "POST",
url: "http://www.serverA.com/process.php",
dataType: "json",
data: dataText,
error: function(request,error){
alert(error);
},
success: function(request) {
alert(request.length);
}
});