Search Results

Search found 1 results on 1 pages for 'gaaaylooord'.

Page 1/1 | 1 

  • $.each - wait for jSON request before proceeding

    - by GaaayLooord
    I have an issue with the below code: the jQuery.each is speeding on without waiting for the JSON request to finish. As a result, the 'thisVariationID' and 'thisOrderID' variables are being reset by the latest iteration of a loop before they can be used in the slower getJSON function. Is there a way to make each iteration of the the .each wait until completion of the getJSON request and callback function before moving on to the next iteration? $.each($('.checkStatus'), function(){ thisVariationID = $(this).attr('data-id'); thisOrderID = $(this).attr('id'); $.getJSON(jsonURL+'?orderID='+thisOrderID+'&variationID='+thisVariationID+'&callback=?', function(data){ if (data.response = 'success'){ //show the tick. allow the booking to go through $('#loadingSML'+thisVariationID).hide(); $('#tick'+thisVariationID).show(); }else{ //show the cross. Do not allow the booking to be made $('#loadingSML'+thisVariationID).hide(); $('#cross'+thisVariationID).hide(); $('#unableToReserveError').slideDown(); //disable the form $('#OrderForm_OrderForm input').attr('disabled','disabled'); } }) })

    Read the article

1