jquery - javascript is executed only with a breakpoint -


i have weird problem js , jquery.

$('#skip').click(function(e) {    savephoto('skip');    shownextplace();    photo_changed = 0;    return false; }); 

shownextplace() , photo_changed = 0; executed when add breakpoint. code of savephoto(); basic. submit request depending on status , number of elements in places array.

function savephoto( status )   {       if ( places.length <= 5 )       {           // load more places           $('#loadmore').val('1');       }        // don't send request on skip unless need more places       if ( status != 'skip' || $('#loadmore').val() == 1 )       {           $.ajax({               url: "url" + status,               cache: false,               data: $('#form_photo').serialize(),               success: function(results){                   // dont load more places until have few                   $('#loadmore').val('0');                    if ( results != '[]' )                   {                       ( var in results )                       {                           places.push( results[i] );                       }                   }               }           });       }   } 

any idea on why happens or how can debug better problem?

the async xhr call

$.ajax({ ... }) 

is arriving while breakpoint there, when not run breakpoint, xhr request still in-flight when code reached.

maybe should have callback $.ajax call shows next place after places have loaded.

you have $.ajax handler call shownextplace if boolean needstoshownextplace true, , have shownextplace set boolean if called when there no next places show.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -