jQuery function calling multiple Ajax functions; only first AJAX works -
i'll seek create broad possible (i'm new working ajax) digress.
currently, have function calls different functions - so, getcontents() calls getweather(),getmovies(), etc.
in each of said getxxxx() functions, there ajax phone call php stuff - utilize function go through info , take need - fine , dandy.
however, getweather() executes - next functions never called. below snippet of of relevant code, believe issue seperating ajax, can't , searching hasn't provided me relevant.
i have tried performing need in 1 function no avail - if play order first ajax function works , others never fired.
function getcontent(zipcode){ getweather(zipcode); getmovies(zipcode); getplaces(zipcode); getmoreplaces(zipcode); }
same getmovies, etc
function getweather(zipcode){ $.ajax({ url: '/dshbrd/php/weather.php', data: "zip_code=" + zipcode, datatype: "xml", type: 'post', async: 'false', success: parseweatherxml }); }
same parsemoviesxml,etc.
function parseweatherxml(xml){ $(xml).find("channel").each(function(){ /*do stuff*/ }); }
i realize more or less 'newbie' question, apologies if i'm using wrong words/didn't search hard enough. funny thing is, php files executed on network (at to the lowest degree in chrome) , returning relevant info - issue seems more or less involve successes not beingness evaluated. well, first success is, anyway.
edit: should mention, in no way 'final' code - plan 1 phone call , like, bug has perplexed me @ prototype stage.
ajax requests asyncronous, thankfully homecoming object extends deferred object, utilize like:
function getweather(zipcode){ homecoming $.ajax({ url: '/dshbrd/php/weather.php', data: "zip_code=" + zipcode, datatype: "xml", type: 'post', async: 'false', success: parseweatherxml }); } function getcontent(zipcode){ getweather(zipcode).done(function () { getmovies(zipcode).done(function () { getplaces(zipcode).done(function () { getmoreplaces(zipcode) }); }); }); }
note each getx function returns result of ajax request, can utilize .done of deferred object.
jquery ajax
No comments:
Post a Comment