Note that there are some explanatory texts on larger screens.

plurals
  1. PObind multiple functions to ajax success call
    text
    copied!<p>Is it possible to bind multiple ajax functions to an ajax success call?</p> <p>For instance, I have teh following code:</p> <pre><code>$('#deals').each(function() { var city_slug = $(this).data('city'); $(".dealloader").show(); //load deals setTimeout(loadDeals, 3000); }); </code></pre> <p>loadDeals function = </p> <pre><code> function loadDeals() { var city_slug = $("#deals").data("city"); //var position = $(this).position(); $.ajax({ cache: false, type: "POST", url: "get_deals.php", data: {'city' : city_slug}, success: function(html) { showYelpStars(function() { $('.dealloader').hide(); $('#deals').append(html); }); } }).done(function( msg ) { // }); } </code></pre> <p>yelp Stars Function =</p> <pre><code> function showYelpStars(callback){ $('.yelpreviews').each(function() { var passurl = $(this).data('yelpurl'); var passname = $(this).data('name'); var passstreet = $(this).data('address'); var passcity = $(this).data('city'); var passstate = $(this).data('state'); var passreview = $(this).data('yelp'); if (passreview.val = '1' &amp;&amp; passname !== ""){ $(this).load('yelpreviews.php', {yelp: passreview, name : passname, address : passstreet, city : passcity, state : passstate} ); } }); callback(); } </code></pre> <p>Function showYelpStars triggers properly within the success call, however, being that its a live API call to yelp, it takes a few seconds to get the full results, All the content on the page is loaded and a few seconds later the yelp response comes in. I'm trying to figure out how to keep my loader showing until everything comes back as a success.<br> Thanks in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload