dongxi4235
dongxi4235
2013-09-05 06:30

在Firebug中的参数列表之后的SyntaxError:missing)

已采纳

I am getting the following syntax error from 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                                
        }); 
    }
});

This is the JSON object being passed by the PHP script $data[]=array("code"=>$code,"title"=>$title,"lecturer"=>$lecturer,"description"=>$description);

I have spend 1 hour debugging but I can't find the syntax error. Can you guys help me out?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • dsa111111 dsa111111 8年前

    Replace

    $("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>"); 
    

    With

    $("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>");  
    

    Your concating was wrong.Use a good editor to traceout.

    点赞 评论 复制链接分享
  • dpqmu84646 dpqmu84646 8年前

    Replace This in your Code

    $.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>");
    });
    
    点赞 评论 复制链接分享
  • dtgvl48608 dtgvl48608 8年前

    can you please used this

    replace this code

          $.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
    
    
               });
    
               }
    
        });
    
    点赞 评论 复制链接分享
  • dongzhi5386 dongzhi5386 8年前

    You are not closing your td tag.

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

    Replace Your code with below

    $("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>"
    ); 
    
    点赞 评论 复制链接分享