Need to check it, the pattern will become the following
$(function () {
Var selectData=https://bbs.csdn.net/topics/null;
$(' # id_select2_demo1). Click ();
$(' # id_select2_demo1). Click (function () {
If (selectData=null https://bbs.csdn.net/topics/={
$. Ajax ({
Type: "post",//want to use the post way
Async: false,
Url: "LEOHBHUBPLANT001. Aspx/GetHubCode",//method in the page and name
ContentType: "application/json; Charset=utf-8,
"DataType: "json",
Success: the function (data) {
SelectData=https://bbs.csdn.net/topics/data.d;//return data with the data. D for content
},
Error: function (err) {
alert(err);
}
});
}
$(' # id_select2_demo1). Select2 ({
Placeholder: 'please select',
AllowClear: true,
Data: selectData,
Cache: true
});
})
});
CodePudding user response:
In the onl oad method or $(function () {} to select Settings in style or the style of the default HTML Settings first