如何将 JavaScript $.post 结果插入文本字段


how can i insert javascript $.post result into textfield

如何将javascript $.post结果插入文本字段。 下面是我的代码。但它不起作用

$.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" />

不确定你从哪里得到随机的代码,但它在jQuery中非常简单:

$.post("scripts/service_getmaxPrice.php", {id:id}, function(data){
  $('#maxPrice').val(data);
});

如果您正在填充div 或其他内容而不是表单字段,则它将是 $('#maxPrice').html(data)$('#maxPrice').text(data)

试试这个:

$.post("scripts/service_getmaxPrice.php", {id:id}, function(data){
    $("#maxPrice").val(data);
});