After jQuery obtains json, it uses zy_tmpl to generate a drop-down menu. jsonzy_tmpl_PHP tutorial

Source: Internet
Author: User
After jQuery obtains json, it uses zy_tmpl to generate the drop-down menu, jsonzy_tmpl. After jQuery obtains json, it uses zy_tmpl to generate a drop-down menu. jsonzy_tmpl writes an article about AppCan development for the first time. someone has written an article about jQuery or native Ajax interaction with json, then I will write jQuery to get json and use zy_tmpl to generate the drop-down menu, jsonzy_tmpl

The first time I wrote an article about AppCan development, someone wrote about jQuery or native Ajax interaction with json, then I will write a little bit about the example of generating a drop-down menu using zy_tmpl after obtaining json using jQuery during the development process.

The json part generated by the PHP server is not written so much, that is, an array $ res is input, and then

The code is as follows:
Echo $ _ GET ['jsoncallback']. "(". json_encode ($ res ).")";

In the AppCan template, add a drop-down menu. my menu is:

 

Select a building group:

Building Name

Loading Data. please wait.

Then join in:

function getlq(){  $.getJSON('http://localhost/json.php?jsoncallback=?', function(data) {    var tmpl='${BuildingName}';    $("#lc").html("");    $("#lc").append(zy_tmpl(tmpl,data,zy_tmpl_count(data)));  })}

In this way, when onload, onchange, and onclick are executed, the select update can be implemented.

The above is all the content of this article. I hope you will like it.

Please take a moment to share your article with your friends or leave a comment. Thank you for your support!

Parse wrote an article about AppCan development for the first time. someone wrote about interaction between jQuery or native Ajax and json, so I will write a little bit...

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.