[英]jQuery Ajax population of dropdowns
我對Ajax的3個下拉列表的動態填充有疑問
$.ajax({
url:"loadPersons",
success:function(data) {
loadPersons(data);
},
error: function (xhr, ajaxOptions, thrownError) {
}
});
這是我的另一個阿賈克斯
$.ajax({
url:"loadCars?personId=8796093056989",
data:{"personId":personId},
success:function(data) {
loadCars(data);
},
error: function (xhr, ajaxOptions, thrownError) {
}
第一個返回所有人,第二個返回具有指定ID的人的汽車。 但是,當我按第一個按鈕時,所有對象都進入第二個下拉菜單。 您知道如何進行過濾嗎?
你不應該使用類似
url:"loadCars?personId="+$('#persons-ddl').val()
嗎?
將您的第二個ajax調用更改為:
$.ajax(
{
url:"loadCars",
data:
{
"personId":personId // this is the id of the selected person in your person combobox
},
error: function (xhr, ajaxOptions, thrownError)
{
}
}).done(function(data)
{
loadCars(data);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.