0

我有一个data包含一些信息的对象。然后我添加一些其他信息,如下所示:

table_company.find('tr').each(function() {
    data['invoice_data'][this.id] = {
        'title': jQuery(this).find('td:eq(0) strong').text(),
        'value': jQuery(this).find('td:eq(1) input, textarea').val()
    };
});

data通过发送jQuery.post到服务器。服务器上只显示初始数据,这是each循环之前的数据。我还在战利品之后打印了该data对象,并且所有新信息都在其中,但它没有被转移……为什么?

更新:

jQuery.post(
    ajax_url + 'saveInvoice',
    data,
    function(response) {}
)
4

1 回答 1

-1

也许问题是:

您使用this.id但在这种情况下未定义:

试试这个方法:

table_company.find('tr').each(function(i) {
    data['invoice_data'][i] = {
        'title': $(this).find('td:eq(0) strong').text(),
        'value': $(this).find('td:eq(1) input, textarea').val()
    };
});
于 2013-11-03T15:13:39.677 回答