jquery after capturing JSON using Zy_tmpl to generate pull-down menu _php tips

Source: Internet
Author: User
Tags php server

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.