【发布时间】:2020-07-29 08:21:19
【问题描述】:
我是 laravel 和 ajax 的新手...我想在下拉列表中显示所选国家的状态,但是当我从下拉列表中选择国家时,它会完美地从 laravel 中获取数据并在 ajax 中获取。 . 但它无法在 html 选项标签中附加数据.. 有关更多详细信息,我还附上了 ajax 的代码...`
$("#country").change(function(e){
var countryid = $(this).val();
console.log("Change Event Happpened on id : "+ countryid);
$.ajax({
type :"GET",
url :"GetStates/"+countryid,
success : function(statelist){
$("#state").empty();
$("#state").append('<option> Select State...</option>')
$.each(statelist,function (statename,stateid) {
**$("#state").append('<option>' + statename + ' </option>') // This line of code is not working**
console.log("in each function");
});
}
});
})
`
【问题讨论】:
标签: javascript jquery ajax