1.11M Members

ajax should call only once

 
0
 

hi, i want ajax to be called only once, but insted it calls everytime when i click on the button.
my script:

$(document).ready(function(){
  $("#modal-launcher-user").click(function(){
$('#preloader_image_edit').show();      

$.ajax({

  url: "image_edit.php",
  cache: false,

})
  .done(function( html ) {
    $("#preloader_image_edit").hide();
    $( "#results_image_edit" ).append( html );
  });
  });
  });
 
0
 
$('#modal-launcher-user').unbind('click');

Will remove the click handler.

 
2
 

That is what jquery's .one() is for.

$("#modal-launcher-user").one('click', function() {
    ...
});
Question Answered as of 6 Months Ago by pritaeas and Airshow
 
0
 

thnx :)

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: