The first time I wrote an article about Appcan development, and someone wrote about jquery or native Ajax interacting with JSON, I wrote a little bit about the example of a Drop-down menu that I used when I was using jquery to get JSON in my development process. Zy_tmpl
The part of the PHP server that generates JSON does not write that much, it is to enter an array $res, and then
Copy Code code as follows:
echo $_get[' Jsoncallback ']. "(" . Json_encode ($res). ")";
In the Appcan template, first add a drop-down menu, my menu is:
<!--drop-down list starts-->
<div class= "Ui-has-label" >
<label class= "Ui-select" > select Complex:</label>
<div class= "Ui-select" >
<div class= "ui-btn ui-btn-icon-right ui-btn-corner-all ui-btn-b" >
<span class= "Ui-btn-inner ui-btn-corner-all" >
<span class= "Ui-btn-text" > Floor name </span>
< Div class= "Ui-li-link-alt ui-btn ui-btn-corner-right Ui-shadow" >
<span class= "Ui-icon ui-icon-arrow-d Ui-icon-shadow "></span>
</div>
</span>
<select name=" LC "id=" LC " selectedindex= "0" id= "select-choice-0" onchange= "Zy_slectmenu (this.id)" >
data loading, please wait
</select>
</div>
</div>
</div>
<!--drop-down List end-->
Then add in:
function Getlq () {
$.getjson (' http://localhost/json.php?jsoncallback=? '), function (data) {
var tmpl= ' < Option value= "${buildingid}" >${BuildingName}</option>;
$ ("#lc"). HTML ("");
$ ("#lc"). Append (Zy_tmpl (Tmpl,data,zy_tmpl_count (data));
})
This enables the implementation of the GETLQ () in onload or onchange, onclick, and the update of the Select.
The above mentioned is the entire content of this article, I hope you can enjoy.
Please take a moment to share the article with your friends or leave a comment. We will sincerely thank you for your support!