我有以下情况:
function searchProduct(cod) {
var msg = "";
var url = '<c:url value="/user/SeachProduct?cod="/>';
$.getJSON(url + cod,
function (ajax) {
$.each(ajax.product, function (k, value) {
$("#formUser").find($('[name="product.' + k + '"]')).each(function () {
setElementValue(this, value, 'product.' + k);
});
});
});
}
如果您使用在输入中包含标记的表单,则此方法有效:
但我不想使用表单...我只是想使用表格并在标签中填充数据:
<span>
<table><tr>
<td><span class="TextoTabela">${product.email}</span></td></tr></table>
我该怎么做?
答案 0 :(得分:0)
您需要修改您的javascript才能实现它:
function searchProduct(cod) {
var msg = "";
var url = '<c:url value="/user/SeachProduct?cod="/>';
$.getJSON(url + cod, function (ajax) {
var myTable = "<tr><td>No records</td></tr>";
$.each(ajax.product, function (k, value) {
myTable += '<tr><td><span class="TextoTabela">'+value+'</span></td></tr>';
});
$("#mytable").html(myTable);
});
}
您的HTML:
<table id="mytable"></table>
多数民众赞成,希望它有所帮助!
答案 1 :(得分:0)
{"contaPagar": {"@resolves-to": "contaPagar","cod": 3,"titulo": "CHEQUE","numeroTitulo": "201111-Bradesco","status": "PAGO","valor": "5999.99","valorTotal": "5999.99","mora": "0.00","multa": "0.00","dataPagamento": "10/10/2014","dataVencimento": "10/10/2014","dataEmissao": "01/10/2014","pessoa": {"cod": 7,"email": "silvio@sbt.com.br","endereco": "Rua do Silvio","bairro": "Morumbi","cidade": "São Paulo","uf": "SP","cep": "00000-000","foneCel": "(22)22222-2222","ativo": true,"nome": "Silvio Santos","nomePai": "Pai do Silvio","nomeMae": "Mae do Silvio","foneRes": "(11)1111-1111","dataCadastro": "01/10/2014","dataNasc": "01/10/1920","dataAtualizacao": "11/10/2014","cpf": "797.137.372-45"}}}