【问题标题】:SyntaxError: missing ) after argument list in FirebugSyntaxError: missing ) 在 Firebug 中的参数列表之后
【发布时间】:2013-09-05 06:30:21
【问题描述】:

我从 firebug 收到以下语法错误:

SyntaxError: missing ) after argument list

 $.ajax({    //create an ajax request to load_page.php
    type: "POST",
    url: "display.php",
    data:{faculties:faculty},            
    dataType: "json",   //expect json to be returned                
    success: function(response)
    {                    

        $.each(response,function(i,item)
        {
            $("table tbody").append("<tr><td>"+response[i].code+"</td>"+"<td>"+response[i].title"</td>"+"<td>"+response[i].lecturer"</td"+"<td>"+response[i].description"</td></tr>"); 
            // The line above is giving me the 
            // syntax error , i cant figure out what's wrong                                
        }); 
    }
});

这是 PHP 脚本传递的 JSON 对象 $data[]=array("code"=&gt;$code,"title"=&gt;$title,"lecturer"=&gt;$lecturer,"description"=&gt;$description);

我花了 1 小时调试,但找不到语法错误。你们能帮帮我吗?

【问题讨论】:

    标签: php jquery debugging firebug


    【解决方案1】:

    替换

    $("table tbody").append("<tr><td>"+response[i].code+"</td>"+"<td>"+response[i].title"</td>"+"<td>"+response[i].lecturer"</td"+"<td>"+response[i].description"</td></tr>"); 
    

    $("table tbody").append("<tr><td>"+response[i].code+"</td>"+"<td>"+response[i].title+"</td>"+"<td>"+response[i].lecturer+"</td>"+"<td>"+response[i].description+"</td></tr>");  
    

    您的连接有误。使用好的编辑器进行跟踪。

    【讨论】:

      【解决方案2】:

      你没有关闭你的td标签。

      "+response[i].lecturer+"</td"+"<td>"+
      ---------------------------^^------
      

      用下面的代码替换你的代码

      $("table tbody").append("<tr><td>"+
          response[i].code+
          "</td><td>"+
          response[i].title+
          "</td><td>"+
          response[i].lecturer+
          "</td><td>"+response[i].description+
          "</td></tr>"
      ); 
      

      【讨论】:

        【解决方案3】:

        你能用这个吗

        替换此代码

              $.ajax({ //create an ajax request to load_page.php
                     type: "POST",
                     url: "display.php",
                     data: {
                           faculties: faculty
                     },
                    dataType: "json", //expect json to be returned                
                    success: function (response) {
        
                    $.each(response, function (i, item) {
                                  $("table tbody").append("<tr><td>" + response[i].code + "</td><td>" + response[i].title + "</td><td>" + response[i].lecturer + "</td><td>" + response[i].description + "</td></tr>");
                                 //The line above is giving me the syntax error , i cant figure out whtas wrong
        
        
                   });
        
                   }
        
            });
        

        【讨论】:

          【解决方案4】:

          在你的代码中替换它

          $.each(response,function(i,item)
          {
          $("table tbody").append("<tr><td>"+response[i].code+"</td>"+"<td>"+response[i].title"</td>"+"<td>"+response[i].lecturer"</td>"+"<td>"+response[i].description"</td></tr>");
          });
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2013-03-11
            • 2018-06-15
            • 1970-01-01
            • 2017-11-04
            • 2019-05-30
            • 2020-03-03
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多