I'm using a click event to capture some data, query a remote server and then display the results.
The issue is the results alert shows, before the .ajax request completes. Any way to delay the alert until the results are available ?
This is what I have so far..
$(".img").click(function(e){
e.preventDefault();
var data = $(this).attr("data")
var info = data.split(',');
var query = '';
$.ajax({ url : 'http://DOMAIN/' + info[5],
success: function(response) {
console.log (response);
query= response;
}
});
alert(info[0] + ' ' + info[1] + ' ' + query);
});
Thanks