I\'m trying to automatically run an ajax url when my page is fully loaded using .load()
function. It seems my code doesn\'t work.
Other information:
<Please check the error in your browser console
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
I am really puzzled why you need to load a tracking pixel via Ajax:
I used to work in SEO and we would just include the link to the tracking pixel in an image e.g. via
<img src="https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748" width="1" height="1">
.
Then you have no cross domain issues, no ajax, no worries.It just records on their site that the page loaded has your affiliate code (and probably drops a cookie at the same time).
This is completely working but just shows this error:
XMLHttpRequest cannot load https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
This might not work from yout local host but will work properly from any server.
And still there is any error try this code:
$(document).ready(function(){
$.ajax({
url:'https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748',
success:function(data)
{
alert(data);
}
})
});