javascript 语法错误:预期的表达式,得到 '}'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32527323/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 15:25:31  来源:igfitidea点击:

SyntaxError: expected expression, got '}'

javascriptjquery

提问by Jose Latouchet Jr.

I'm starting to program with JS and PHP and my question is why the console give this error, I search a lot of websites but without clues about this. If you can help I'll apreciate it

我开始用 JS 和 PHP 编程,我的问题是为什么控制台会出现这个错误,我搜索了很多网站,但没有任何线索。如果你能帮助我会很感激

<script>  
  $(function(){
    $("#btn_enviar").click(function(){
      $.ajax({
        type: "post",
        url: "registro.php",
        data: $("#form_members").serialize(),
        success: function()
      });
    });
    return false;          
  });
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

回答by J Santosh

you forgot {}after function()

你忘了{}function()

Updated JS

更新了 JS

$(function () {
$("#btn_enviar").click(function () {
    $.ajax({
        type: "post",
        url: "registro.php",
        data: $("#form_members").serialize(),
        success: function (){}
    });
});
return false;
});