语法错误,无法识别的表达式分析tr元素

问题描述:

我在jQuery的做$.post()和响应接收<tr>元素时,类似于此:语法错误,无法识别的表达式分析tr元素

<tr class="editable" id="527a84eb-b430-4a33-9079-a19d00ca373c"> 
    <td class="date">2013-04-05 
    </td> 
    <td class="amountType">Credit 
    </td> 
    <td class="amount">$5.00 
    </td> 
    <td class="category">Meals 
    </td> 
    <td class="notes"></td> 
    <td data-expense-report-line-item-id="527a84eb-b430-4a33-9079-a19d00ca373c" class="actionItems"> 
     <button class="deleteLineItem">Delete</button> 
     <button class="editLineItem">Edit</button> 
    </td> 
</tr> 

我打算在我使用此功能表注入该行:

$.post('@Url.Content("~/ExpenseReports/SaveLineItem")', { 
    Date: date, 
    Amount: amount, 
    AmountType: amountType, 
    ExpenseCategoryId: category, 
    Notes: notes, 
    ExpenseReportId: expenseReportId, 
    ExpenseReportLineItemId: expenseReportLineItemId 
}, function (data) { 
    if ($('table tbody').length > 1) { 
     $('table tbody tr:last').slideUp(200, function() { 
      $(data).insertAfter('table tbody tr:first').slideDown(); 
     }); 
    } else { 
     alert(data); 
     $(data).appendTo($('table tbody')); 
    } 
    row.find('td.date:first input.date').val(''); 
    row.find('td.amount:first input.amount').val(''); 
    row.find('td.amountType:first select.amountType').val('Debit'); 
    row.find('td.category:first select.category').val(''); 
    row.find('td.notes:first input.notes').val(''); 
}, 'html'); 

此处的意图是在tbody元素的第一行之后插入此行。然而,当我尝试这个,我得到一个JavaScript错误回:

Uncaught Error: Syntax error, unrecognized expression: <tr class="editable" id="527a84eb-b430-4a33-9079-a19d00ca373c"> 
     <td class="date"> 
      2013-04-05 
     </td> 
     <td class="amountType"> 
      Credit 
     </td> 
     <td class="amount"> 
      $5.00 
     </td> 
     <td class="category"> 
      Meals 
     </td> 
     <td class="notes"> 

     </td> 
     <td data-expense-report-line-item-id="527a84eb-b430-4a33-9079-a19d00ca373c" class="actionItems"> 
      <button class="deleteLineItem">Delete</button> 
      <button class="editLineItem">Edit</button> 
     </td> 
    </tr> 

在我看来,这应该可以通过jQuery解析。我究竟做错了什么?

+0

我不认为''

S可向下滑动,但不会是你正在寻找 – 2013-04-11 16:33:05
+1

使用Firebug的问题在这里(所以无论版本的jQuery SO使用)它解析你的HTML罚款(跑''('

..你的东西..)') – Mikeb 2013-04-11 16:34:51
+0

嗯......我想知道这是否是Chrome的问题.. 。 – 2013-04-11 16:38:23

回答

问题是因为jQuery 1.9,与1.10.2它工作得很好

问题是因为jQuery 1.9,与1.10.2它工作得很好

问题是因为jQuery 1.9,与1.10.2它工作得很好