在jquery回调函数中调用两次如何避免

时间:2018-02-14 10:09:30

标签: javascript jquery

我正在尝试编写API调用其命中数据库但在此代码中回调操作调用多次所以请尝试理解我的问题  在下面的代码不能正常工作,请更正

$(document).ready(function() {
  // reject article requests start
  var article;
  $(".resend-article-request").click(function() {
    var articleId = $(this).attr("data-article-id");
    article = articleId;
    $("#articleRejectModal").foundation('open');

  });

  $(".editingReasons").click(function() {
    var formData = new FormData($('#articleEditForm')[0]);
    formData.append('articleId', article)
    var articleReviewCallBacks = {
      "success": function(data) {
        $('#articleEditForm')[0].reset();
        alert("Sending for Re-Write article.");
        window.location.reload();
      },
      "error": function(data) {
        alert("error");
        window.location.reload();
      }
    };
    window.pmprojectutils.getResponse('POST', '/api/article/rewrite', formData, articleReviewCallBacks, true);
  })
});

0 个答案:

没有答案