Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  26] [ 7]  / answers: 1 / hits: 11378  / 11 Years ago, mon, december 9, 2013, 12:00:00

I am making a ajax request in jquery as below. This ajax request gets images dynamically. And the image is always different image depending on the value of num



$.ajax({
type: POST,
url: ABC.php?num=1,
success: function(response) {
if(response == 1) {
//some code
}
else {
// Here I am not able to set image content.
$(#image).attr(src, data:image/png;base64,' + response + ');
}
}
});


Is there a way to set image content using the response of the ajax request. Thanks.


More From » jquery

 Answers
6

You have some unneeded single quotes there. Use this:



$(#image).attr(src, data:image/png;base64, + response);

[#49707] Sunday, December 8, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lamarmaximiliand

Total Points: 388
Total Questions: 104
Total Answers: 104

Location: Oman
Member since Fri, Dec 23, 2022
1 Year ago
;