Home > Backend Development > PHP Tutorial > jQuery uses zy_tmpl to generate drop-down menu after getting json_PHP tutorial

jQuery uses zy_tmpl to generate drop-down menu after getting json_PHP tutorial

WBOY
Release: 2016-07-13 09:59:53
Original
964 people have browsed it

jQuery uses zy_tmpl to generate a drop-down menu after getting json

This article mainly introduces the example of using jQuery to get json and then using zy_tmpl to generate a drop-down menu during my development process. Although it is the first I will write about the development of AppCan at once, friends in need can refer to it.

This is my first time writing an article about AppCan development. Someone has written about the interaction between jQuery or native Ajax and json. Then I will briefly write about an example of using jQuery to obtain json and then using zy_tmpl to generate a drop-down menu during my development process.

The part where the PHP server generates json is not so much, just input an array $res, and then

The code is as follows:


echo $_GET['jsoncallback'] . "(" . json_encode($res) . ")";

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

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

楼名

1 2

3

4

5

6

1

2

3

4

5

6

7

function getlq(){

$.getJSON('http://localhost/json.php?jsoncallback=?', function(data) {

var tmpl='';

$("#lc").html("");

$("#lc").append(zy_tmpl(tmpl,data,zy_tmpl_count(data)));

})

}

7 8

9

10 11

12

14 15 16 17 18
Building name
Then add in: ?
1 2 3 4 5 6 7 function getlq(){ $.getJSON('http://localhost/json.php?jsoncallback=?', function(data) { var tmpl=''; $("#lc").html(""); $("#lc").append(zy_tmpl(tmpl,data,zy_tmpl_count(data))); }) }
In this way, when you execute getlq(); on onload, onchange, or onclick, you can update the select. The above is the entire content of this article, I hope you all like it. http://www.bkjia.com/PHPjc/975125.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/975125.htmlTechArticleUse zy_tmpl to generate a drop-down menu after jQuery obtains json. This article mainly introduces the use of jQuery to obtain json during my development process. An example of using zy_tmpl to generate a drop-down menu, although this is the first time...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template