简体   繁体   English

JavaScript错误:需要标识符,而看到了'}'

[英]Javascript Error: Expected an identifier and instead saw '}'

I'm using http://www.jslint.com/ to validate a small script and it's giving me this error 我正在使用http://www.jslint.com/来验证一个小脚本,这给了我这个错误

Expected an identifier and instead saw '}'
On line 13: })

I need help to understand what is wrong with the script and how to stop the error. 我需要帮助以了解脚本出了什么问题以及如何停止该错误。 Also since i built this script with tips found online please let me know if it has other errors no mentioned by the debugger. 另外,由于我使用在线找到的提示构建了该脚本,因此请告知我是否还有调试器未提及的其他错误。 Full code: 完整代码:

(function($) {
  $(".acf-get-content-button").click(function(e) {
    e.preventDefault();
    $(".fa").addClass("fa-cog fa-spin fa-4x");
var $contentWrapper = $("#acf-content-wrapper");
var postId = $contentWrapper.data("id");

    $.ajax({
        url: "/ajax.php",
        "type": "POST",
        "data": {
          "post_id": postId
        },
      })
      .done(function(data) {
        $(".fa").removeClass("fa-cog fa-spin fa-4x");
        $contentWrapper.append(data);
        $("#acf-content-wrapper a").attr("target","_blank");
        $("#acf-content-wrapper").bind("contextmenu", function(e) {
        return false;
        });
        $(".acf-get-content-button").removeClass().addClass(".acf-get-content-button")
      });
  });
  $(".acf-get-content-button").mouseup(function() {
    if (event.which == 1) {
      $(".acf-get-content-button").hide();
    }
  });
})(jQuery);

I suppose that the jslint error is the last comma in 我想jslint错误是最后一个逗号

"data": {
    "post_id": postId
},

It should be 它应该是

"data": {
    "post_id": postId
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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