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

时间:2013-09-05 06:30:21

标签: php jquery debugging firebug

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

  参数列表

之后

SyntaxError:missing)

 $.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"=>$code,"title"=>$title,"lecturer"=>$lecturer,"description"=>$description);

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

4 个答案:

答案 0 :(得分:3)

替换

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

仲裁错误。使用好的编辑器进行追踪。

答案 1 :(得分: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>"
); 

答案 2 :(得分:0)

你可以用这个

吗?

替换此代码

      $.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


           });

           }

    });

答案 3 :(得分:0)

在您的代码中替换它

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