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 );
  });
  });
  });

Recommended Answers

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

$("#modal-launcher-user").one('click', function() {
    ...
});
Jump to Post

All 3 Replies

Re: ajax should call only once 80 80
$('#modal-launcher-user').unbind('click');

Will remove the click handler.

Re: ajax should call only once 80 80

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

$("#modal-launcher-user").one('click', function() {
    ...
});
Re: ajax should call only once 80 80

thnx :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.