I created a small js containing a code to track and save through an ajax call the coordinates of the click on a web page. In a website (domain2) is entered in the head
<script src="http://www.domain1.com/scan/track/mousehandle.js"></script>
that contain code like this:
$('*').on('click', function (e) {
// make sure the event isn't bubbling
if (e.target != this) {
return;
}
$.ajax({
type: "POST",
url: "http://www.domain1.com/scan/track/php/ajaxcall.php",
data: { x: e.pageX, y: e.pageY }
})
.done(function( msg ) {
alert( "Data Saved: " + msg );
});
}
But when i click on the domain2 webpage, return this:
XMLHttpRequest cannot load http://www.domain1.com/scan/track/php/ajaxcall.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.domain2.com' is therefore not allowed access.
How can i save click coordinates trapped by my javascript positioned on another domain??
Thanks in advance