我可以用一些帮助 . 我已经将我在PHP中创建的数组中的对象加载到一堆输入框中 . 对象用于购物车:价格,数量和总价格 . 虽然数据加载正常,但它似乎是只读的 .
例如,数量的输入文本值为1,我无法更改它 .
我想能够更改数量而无需返回我的MySQL表 .
我可以使用常规Ajax做得很好,但是当我使用常规Ajax时,如果没有像我所有其他ajax函数一样刷新,项目将无法加载 .
这是代码 .
function updates(){
$.getJSON("classes/cartlist.php", function(data) {
$("#cart_list, #cart_table").empty();
$.each(data.result, function(){ $("#cart_list, #cart_table").append(
"<tr id='"+this['id']+"'>
<td> "+this['pro_title']+" </td>
<td> <input type='text' id='price-"+this["p_id"]+
"' class='price' pid='"+this["p_id"]+
"'value='"+this["price"]+"' />
</td>
</tr> ");
});
});
这不是一切,但另外两个输入框只是一样的东西 . 我认为如果我这样离开它会更容易阅读 .
编辑:这是数量输入文本框的样子,因为有人问 .
<td><input type='text' id='qty-"+this["p_id"]+"' class='qty' pid='"+this["p_id"]+"' value='"+this["qty"]+"' />
编辑:好的所以我发现我无法更改文本的原因,那就是与JSON一起使用的设置间隔函数
function done() {
setTimeOut (
function(){
updates();
}, 300)
}
但如果我摆脱它,我将不得不刷新页面以获取我的数据..
1 回答
我认为追加字符串有一个错误