1

I try to assign the value of "data.pic_name" to "imgSrc" by this following code

var imgSrc = '';
$.ajax({
     url : "../NanglaeGov/getOneProPicture.do?owner="+data[i].tour_id,
     type : "POST",
     success : function(data) {
    imgSrc = data.pic_name;
    alert(imgSrc);
     },
      error : function(data, status, er) {
   alert('error');
   $("#loader").hide();
          }
     });
alert(imgSrc);

When it alert in the loop imgSrc has a value of data.pic_name but alert at the last line is completely blank.

0 Answers0