【问题标题】:Uncaught SyntaxError: missing ) after argument list - Other answers did not solve itUncaught SyntaxError: missing ) after argument list - 其他答案没有解决
【发布时间】:2017-06-05 08:02:38
【问题描述】:

我的 SO 搜索告诉我,当您有一个额外的括号或另一个格式错误(sourcesource 等)时会发生此错误。但是我一遍又一遍地检查我的代码 sn-p ,并且无法发现任何此类问题。但我仍然收到错误:

Uncaught SyntaxError: missing ) after argument list

以下是我的脚本。问题是为什么我会收到此错误,以及如何解决此问题。

<?php 

$(document).ready(function() {
    alert("scripts.js detected");//check

    alert($("input#theInput").val());//check



    /*
    *
    */
    $("form#theInputForm").submit(function(event) {
        event.preventDefault();

        if ($("input#theInput").val() == '') {
            alert("Please enter a the value.");
        } else {

            $(".inputFormWrapper").css("height") = "10vh";
            $(".otherSectionWrapper").show();


            var theEntered = $("input#theInput").val();


            $.ajax(
                url: "get_the_data_two.php",
                method: "get",
                data: {
                    theFromUser: theEntered
                },
                success: function(otherData, textStatus, jqXHR) {

                    alert(otherData);//check

                },
                error: function(jqXHR, textStatus, errorThrown) {
                    alert("textStatus: " + textStatus + " \nerrorThrown: " + errorThrown);//check
                }
            );

        }

    });




});

?>

【问题讨论】:

  • 寻找丢失的)
  • 使用 jslint 检查
  • Ajax 对象错误 { 缺少像这样的更改 $.ajax({
  • Object 传递给$.ajax({ ... })
  • $(".inputFormWrapper").css("height") = "10vh"; 是一个错误的分配

标签: javascript jquery


【解决方案1】:

两件事 :: 高度分配不正确和 ajax 语法。

你的 else 部分应该如下:

{
    $(".inputFormWrapper").css("height","100px");
    $(".responseSectionWrapper").css("height","90px");


    var tmsiEntered = $("input#tmsiInput").val();


    $.ajax({
        url: "get_auth_data_two.php",
        method: "get",
        data: {
            tmsiFromUser: tmsiEntered
        },
        success: function(responseData, textStatus, jqXHR) {

            alert(responseData);//check

        },
        error: function(jqXHR, textStatus, errorThrown) {
            alert("textStatus: " + textStatus + " \nerrorThrown: " + errorThrown);//check
        }
    });

}

如有疑问,请查看 API:http://api.jquery.com/css/

【讨论】:

    【解决方案2】:

    在我错过的回调函数中,在参数列表中 示例:#####

    function one(arg,callback){
      alert("hay $(arg)");
      callback();
    }
    
    one('avinash'function(){ //one('avinash',function(){ if ',' missing will get error
      alert("after execution");    
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-25
      • 1970-01-01
      • 2018-11-13
      • 2019-09-16
      相关资源
      最近更新 更多