javascript - Using ajax o display image -


Can someone help fix it? It works when the image is added directly to the code, but when it is tried to retrieve the image path from MySQL using Ajax, it does not work.

The line should work as I want: 'back': {'url': imageX, 'img': null},

The code works:

  (function () {var image = {'back': {'url': 'img / logo.jpg', 'img': null}, 'front ':' 'Url': 'img / another.jpg', 'img': null}}  

but does not work though Ajax can successfully obtain data from mysql? Ajax ({type: 'GET', url: 'php / myphp.php', datatype: 'Jason', success: work (feedback) {var imageX = 'IMG / '[[0] .img +' .jpg ', group X = response [0] .tem; var s = document.getElementById ("CurrentVal"); S.value = imageX; * * / / / Img / logo.jpg}}}); (function () {var image = {'back': {'url': imageX, 'img': null}, 'front': {'url ':' Img / another.jpg ',' img ': null}};

< P> Did you check the imageX value inside your lower function?

If you want to use the imageX variable on your lower function, then it is necessary to have a different scope that you declare it in Ajax success are doing.


Comments