JQuery + AJAX Implementation Dynamic Add Table TR TD Function Example

This example describes the dynamic additive TR TD functionality of jQuery + Ajax implementation. Share to you for your reference, specifically:

Function: AJAX gets the background return data to Table Dynamically add TR / TD

HTML section:

  
AJAX part:

VAR Year = $ (‘# Year’). Val (); // Downlink Box Data VAR Province = $ (‘# province’). VAL ( ); // pull-down frame data $ (‘Table TBody’). HTML (”); $. Ajax ({URL: “/ Plan / Sendjson.html”, TYPE: “get”, data: {‘Year’: Year, ‘province’: province}, DataType: ‘JSON’, SUCCESS: FUNCTION (DATA) {Switch (DATA.MSG) {CASE ‘0’: $ (‘Table TBody’). prepend (‘

】 No data
‘); Break; Case’ 1 ‘: $. Each (Data.Data, Function (i, n) {var $ tr = $ (“
" + " "+ n.year +"  "+"  "+ n.province +"  "+"  "); var $ table = $ ('Table TBody'); $ TABLE.APpend ($ TR);};}}})    PHP background  (Thinkphp Processing):    $ Year = I ('get.year'); $ province = i ('get.province'); $ condition = array (); $ YEAR && $ Condition = Array ('EQ', $ Year); $ Province && $ Condition = Array ('EQ', $ Province); $ DATALIST = M ('Plan') -> WHERE ($ condition) -> select (); IF (false! = $ data) {$ data ['msg'] = '1'; $ DATA ['Data'] = $ DATALIST; Echo Json_Encode ($ data); exit;} else {$ data ['msg' ] = '0'; $ data ['data'] = ''; echo json_encode ($ data); exit;} 

More about jQuery related content is interested Readers can view this topic: “JQuery Forms”, “jQuery operation JSON data skills”, “jQuery form operation skills summary”, “jQuery common plugin and usage summary”, “jQuery extension skill summary “” JQuery Selector Summary “

I hope this article will help you jQuery program.
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment