我有一个用于从数据库中检索名称的ajax,当名称不止一个时,我将它们拆分然后克隆第一个类,这样我就可以在克隆类中拥有另一个名字(第二个)。似乎不起作用,我缺少什么?
$.ajax({
type: "POST",
url: base_url + "c_transfer/viewTransfer/" + transfer_id,
dataType: "json",
success: function (data) {
var all_transferors = data[0]['Transferor_Name'];
var sole_transferors = all_transferors.split(',');
for (transferor_counter = 0; transferor_counter < sole_transferors.length; transferor_counter++) {
if (transferor_counter > 0) {
$('.clone').relCopy({});
$("#transferor_name").val(sole_transferors[transferor_counter]);
} else {
$("#transferor_name").val(sole_transferors[transferor_counter]);
console.log(sole_transferors[transferor_counter]);
}
// console.log(sole_transferors[transferor_counter]);
}
答案 0 :(得分:0)
$("#transferor_name").val(sole_transferors[transferor_counter].val());
您最后需要使用.val()
吗?