SyntaxError:缺少形式参数Firefox

时间:2017-11-18 12:35:35

标签: javascript

这是我的代码,它在Firefox中不起作用。它向我展示了SyntaxError:缺少形式参数。我不知道为什么。问题出在哪儿。它在Chrome中工作

$(document).ready(function() {
  $(document).on("click", ".button", function('click') {
    var last_id = $(".button").val();
    var tagg_id = event.target.id;
    $(".button").html("Loading...");

    $.ajax({
      url: "loadData.php",
      method: "POST",
      data: {
        last_id: last_id,
        tagg_id: tagg_id
      },
      dataType: "text",
      error: function(xhr, status, error) {
        alert(status);
      },
      success: function(data) {
        if (data != "") {
          $(".button").remove();
          $("#last").append(data);
        } else {
          $(".button").html("No more posts");
        }
      }
    });
  });
});

1 个答案:

答案 0 :(得分:0)

应该是:

$(document).ready(function() {
    $(document).on("click", ".button", function(event) {

或者使用更好更清洁的选择器:

$(document).ready(function() {
    $(".button").on("click", function(event) {

您应该阅读jQuery API文档以获得更好的解释:https://api.jquery.com/click/

相关问题