嗨,有没有人可以帮助我解决以下问题。我有jquery ajax get(http get)请求和
有了成功数据,Probelem就是如何将数据绑定到html表单或html辅助类喜欢(@html.下拉列表,@html。文本框),实际上我试图在jquery和ajax的帮助下调用一个视图作为创建和编辑,我卡在某一点,请帮助我,,
我的jquery代码是
$.ajax({
type: 'Get',
url: geturl,
data: {
orderid: $(this).data('id')
},
success: function (response) {
var CustomerID = response.cID;
var ShipName = response.ShipName;
$("#CustomerID").html(CustomerID);
$("#ShipName").html(ShipName);
return false;
},
error: function (e) { alert(e.error); }
});
如何将响应数据绑定到 html 帮助程序类属性,就像我想将 cID 绑定到 CustomerID 一样
我的视图代码是
enter code here
<form id="myform" >
<div>`enter code here`
@Html.Label("Ship Name", "ShipName");
@Html.TextBox("ShipName", "");
</div>
<div class="editor-label">
@Html.Label("Customer", "CustomerID")
</div>
<div class="editor-field">
@Html.DropDownList("CustomerID", String.Empty)
</div>
使用 val
而不是 html
$("#CustomerID").val(CustomerID);
$("#ShipName").val(ShipName);