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
Post a Comment