0

I want to make this Ajax call using get() inside each() function to fetch data from the files, looping through the each().

this is my piece of code:

    jQuery.each(html_files, function(index,post_html){
        jQuery.get(post_html, function(data){
            // do action
        });
    });

here, html_files is an array, containing list of html files.

However, i am only able to fetch the data for the first file. How do i execute this synchronously.

Thanks in advance!

Annapurna
  • 529
  • 1
  • 6
  • 19

1 Answers1

1
jQuery.each(html_files, function(index,post_html){
    jQuery.ajax({
        type:get,
        url:post_html, //or the url to fetch data
        success:function(data){
            alert(data);
         }
    });
});

Check this out