The structure of when this is done depends on how you make your AJAX call. In the tags you've included jQuery, so I'm going to assume you're using the .ajax()
function. For now I'll assume the use of the .then()
callback (show your code if it's different). In that case you'd "change the image" here:
$.ajax({
url: 'someurl.php'
}).then(function() {
// change the image here
});
According to the documentation, .then()
will always be called after the AJAX call completes. There are other, more specific functions such as .done()
or .fail()
which you can use as well. The comment in the code above indicates where you'd perform your action responding to the AJAX call. What action you perform isn't entirely clear. Are you just changing the src
of an img
? Something like this, then:
$('#theImage').prop('src', someUrlValue);
Where you get someUrlValue
is up to you.