69th Day Class text value, JSON pass value and XML pass value

Source: Internet
Author: User

Text Transfer value: Main Page code (read database data)

$Jquery. js "></script>$ (document). Ready (function() {   $(' #btn '). Click (function()   {       $.Ajax ({URL: "Uindex.php",DataType: "TEXT",Success:function(a) {varHang=a.Split(' | '); varstr= "<tr align= ' center ' ><td> codename </td><td> name </td><td> Gender </td><td> National </td><td> Birthdays </td><td>*</td></tr> ";  for(vari=0;i)              {                  varJ=hang[i].Split(‘-‘); STR+ = "<tr align= ' center ' ><td>" +j[0]+ "</td><td>" +j[1]+ "</td><td>" +j[2]+ "</td ><td> "+j[3]+" </td><td> "+j[4]+" </td><td> Delete </td></tr> "; }              $(' #xianshi ').html (str);   }        }); });});</script>

Text pass value (Background page) index1.php

<? PHP include "class/unionmysql-class.php"; $db=new  unionmysql (); $sql= "SELECT * from Info"; $result=$db->querystr ($sql); Echo $result;

JSON value: Main Page code (drop-down list)

$Jquery. js "></script>$ (document). Ready (function() {    $.Ajax ({URL: "Test.php",DataType: "JSON",Success:function(e) {varStr= ";  for(vari=0;i<e.length;i++) {str+ = "<option valur=" +e[i][0]+ ">" +e[i][1]+ "</option>"; }            $(' #nation ').html (str); }    });});</script>

JSON value (background interface) test.php

include "class/unionmysql-class.php"; $db New Unionmysql (); $sql = "SELECT * from Nation"; $result=$db->query ($sql); echo json_encode ($result);      // convert an array to JSON

XML value: Main Page code (drop-down list)

<title>ajax</title><script src= "js/$Jquery. js "></script>$ (document). Ready (function() {    $.Ajax ({URL: "Test.php",DataType: "XML",Success:function(e) {varnation=$ (E). Find (' Nation ').Children (); varStr= ";  for(vari=0;i<nation.length;i++)           {               varcode=$ (Nation[i]). Find (' Code ').text (); varname=$ (Nation[i]). Find (' name ').text (); STR+ = "<option value=" "+code+" > "+name+" </option> "; }           $(' #nation ').html (str); }    });});</script>

XML value (background interface) test.php

<?PHPinclude"Class/unionmysql-class.php";$db=NewUnionmysql ();$sql= "SELECT * From Nation";$result=$db->query ($sql);Echo"<nation>";foreach($result  as $k=$i){    Echo"<shuju{$k}> "; Echo"<code>{$i[0]} </code> "; Echo"<name>{$i[1]} </name> "; Echo"</shuju{$k}> ";}Echo"</nation>";

69th Day Class text value, JSON pass value and XML pass value

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.