jquery - Slide up and slide down div, while not doing multiple ajax request -


i have div can expand, down , up. when expand div, ajax-request made. problem that, when want hide div, ajax-request called again. have tried solve problem variable expanded:

var expanded; $('body').on('click', '#responds .expand_button', function(e) {      e.preventdefault();     var clickedid = this.id.split("-")     var dbnumberid = clickedid[1]; //get number array     var mydata = dbnumberid;      if(expanded != 1) {         $.ajax({             type: 'post',             url: 'process.php',             datatype: 'html',             data: {recordtoexpand: mydata},             success: function(response) { $('#fish_'+dbnumberid).slidetoggle("slow").append(response);  expanded = 1; },             error: function(xhr, ajaxoptions, thrownerror) { alert(thrownerror); }         });     }      if(expanded == 1) {         $('#fish:visible').slideup();         expanded = 0;     } }); 

but don't work. can me?


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -