UPDATE: Let me specify a few things. This GET request (to another domain) should happen after a form submitted through AJAX successfully (it counts the number of conversions coming from a specific referrer). So the response is indeed irrelevant, what matters most is that the GET request is successful, and of course that I keep the code to a minimum.
Quick question, are these two lines pretty much the same thing ? (what I need is a get request to the url) :
$('body').append('<img height="1" width="1" style="border-style:none;" alt="" src="url"/>');
And
$.get(url);
My apologies if this sounds idiotic, but I need to be sure.
Thank you.
In terms of making a GET request to the URL – yes. But in terms of using the data – no.
One creates an image element with
urlas the image source. If the response is not valid image data, rendering it will fail. The GET request will always be made, though.The other makes an Ajax request to
url. If it’s an image resource, the response will contain image data – but you’re going to have a hard time displaying it (you’d have to base64 encode it first and show as adata:URL, or insert it into a canvas element, both of which methods don’t have 100% browser support.) Also, request to remote URLs won’t work.