如何将javascript $ .post结果插入到textfield中。下面是我的代码。但它不起作用
$.post("scripts/service_getmaxPrice.php", {id:id}, function(data){
$("#maxPrice").innerhtml.html(data);
document.getElementById('maxPrice').value =html(data);
});
html代码是
<tr><td class="ttxt" style="text-align:right;">Maximum price</td><td><input type="text" id="maxPrice" class="txt" name="maxPrice" />
答案 0 :(得分:3)
不知道你在那里随机搜索了一些代码,但在jQuery中它真的非常简单:
$.post("scripts/service_getmaxPrice.php", {id:id}, function(data){
$('#maxPrice').val(data);
});
如果您填写的是div或其他内容而不是表单字段,则可以是$('#maxPrice').html(data)
或$('#maxPrice').text(data)
。
答案 1 :(得分:0)
试试这个:
$.post("scripts/service_getmaxPrice.php", {id:id}, function(data){
$("#maxPrice").val(data);
});