简体   繁体   中英

bootbox confirm before ajax call

I have this Javascript code:

this.confirmBox = function(event, data) {
  return bootbox.confirm("Are you sure?", function(result) {
    alert(result); // this returns TRUE as it is supposed to
  });
};

this.beforeSend = function(event, jqXHR) {
  if (this.confirmBox()) {
    // HERE THE AJAX QUERY GETS EXECUTED
  } else {
    return jqXHR.abort(); // HERE WE ABORT IT
  }
};

My problem is that the ajax query gets executed before I confirm within bootbox popup. How do I need to change the line (this.confirmBox()) in order to have the beforeSend function checking if the confirmBox function returns true?

您需要将this.beforeSend放入确认框的函数(结果)....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM