I have found behaviour that makes me trouble in JavaScript. I have two functions:
var show_uploaded = function( data_photo )
that gets informations about uploaded photos as a parameter,
function exif_like(path){/*working with my image*/ console.log('exif_like END'); }
that gets path to every single one uploaded photo as a parameter.
I made code like this:
var show_uploaded = function( data_photo ){
for( var z = 0; z < data_photo.length; z++ ){
var send_image_name = uploaded_photo[z].name;
$.ajax({
data: { compare : send_image_name },
url: 'get_panorama.php',
method: 'POST', // or GET
success: function( path ){
exif_like( path );
console.log('FOR LOOP END');
}
});
}
};
But what I see in console is that "FOR LOOP END" log is displayed before "exif_like END" log. And this causes some unpredictable behaviour in my code.
Is there any solution how to continue for loop after exif_like() function is done?
If the remainder of processes return expected results, and exif_like
actually only performs console.log()
you could try using $.when()
$.when(exif_like( path )).then(function() {console.log("FOR LOOP END")})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With