AjaxͨÐŲÙ×÷JSONÊý¾Ýʵս

µ¼Óï JSONÊý¾Ý²Ù×÷server2 php<?php 1$member[& 39;username& 39;]="aseoe";$member[& 39;password& 39;]="aseoe";$do=$_REQUEST[& 39;do& 39;]; 2$members[& 39;1& 39;][& 39;username& 39;]="°®Ë¼×ÊÔ´Íø";$member

JSONÊý¾Ý²Ù×÷

jsonÊý¾Ý²Ù×÷

server2.php

  1. <?php 
  2.  
  3. //1 
  4. $member['username'] = "aseoe"
  5. $member['password'] = "aseoe"
  6. $do = $_REQUEST['do']; 
  7.  
  8.  
  9. //2 
  10.  
  11. $members['1']['username'] = "°®Ë¼×ÊÔ´Íø"
  12. $members['1']['password'] = "aseoev"
  13. $members['2']['username'] = "¼«ËÙÉè¼Æ"
  14. $members['2']['password'] = "jisu"
  15. $members['2']['address'] = "ÄϾ©ÊÐ"
  16. $members['third']['members']['address'] = "ÄϾ©ÊÐ"
  17.  
  18. //3 
  19.  
  20. class addressClass{ 
  21.     public $address = array(); 
  22.      
  23.     public function setAddress($array){ 
  24.         $this->address = $array
  25.     } 
  26.      
  27.     public function getAddress(){ 
  28.         return $this->address; 
  29.     } 
  30.  
  31. $addressObj = new addressClass(); 
  32. $addressObj->setAddress($members); 
  33.  
  34. switch($do){ 
  35.     case "first"
  36.     echo json_encode($member); 
  37.     break
  38.      
  39.     case "second"
  40.     echo json_encode($members); 
  41.     break
  42.      
  43.     case "third"
  44.     echo json_encode($addressObj); 
  45.     break
  46.      
  47. ?> 

ǰ̨ÏÔʾ

  1. <!DOCTYPE HTML> 
  2. <html> 
  3.     <head> 
  4.         <title>php-JSON2</title> 
  5.         <meta charset="utf-8"> 
  6.         <meta name="viewport" content="width=device-width"> 
  7.         <script src="http://www.aseoe.com/statics/js/jquery-1.10.2.min.js" type="text/javascript"></script>  
  8.         <script type="text/javascript"> 
  9.         $("document").ready(function (){ 
  10.             var url = "server2.php"
  11.             var data = {"do":"first"}; 
  12.              
  13.             $.getJSON(url,data,function(res){ 
  14.                 $("#username").val(res.username); 
  15.                 $("#password").val(res.password); 
  16.             }); 
  17.              
  18.             var data = {"do":"second"}; 
  19.             $.getJSON(url,data,function(res){ 
  20.                  
  21.             $("#members").val(res[1].username); 
  22.             $("#members").val(res.third.members.address); 
  23.             }); 
  24.              
  25.             var data = {"do":"third"} 
  26.             $.getJSON(url,data,function(res){ 
  27.             $("#address").val(res.address[1].username); 
  28.             }) 
  29.         }); 
  30.          
  31.         </script>  
  32.     </head> 
  33.     <body> 
  34.         <h2>һάÊý×é</h2> 
  35.         <input type="text" name="username" id="username" /> <br /> 
  36.         <input type="password" name="password" id="password" /> <br /> 
  37.      
  38.         <h2>¶àάÊý×é</h2> 
  39.         <textarea id="members">  
  40.         </textarea> 
  41.          
  42.         <h2>¶ÔÏó</h2> 
  43.         <textarea id="address">  
  44.         </textarea> 
  45.     <script type="text/javascript"> 
  46.  
  47.      
  48.     </script> 
  49.        
  50.     </body> 
  51. </html> 

 

http://www.aseoe.com/ true AjaxͨÐŲÙ×÷JSONÊý¾Ýʵս http://www.aseoe.com/show-12-468-1.html report <£¿php echo strlen($content) / 2; ?> JSONÊý¾Ý²Ù×÷server2 php<?php 1$member[& 39;username& 39;]="aseoe";$member[& 39;password& 39;]="aseoe";$do=$_REQUEST[& 39;do& 39;]; 2$members[& 39;1& 39;][& 39;username& 39;]="°®Ë¼×ÊÔ´Íø";$member
TAG:Ajax JSON
±¾Õ¾»¶Ó­ÈκÎÐÎʽµÄתÔØ£¬µ«ÇëÎñ±Ø×¢Ã÷³ö´¦£¬×ðÖØËûÈËÀͶ¯³É¹û
תÔØÇë×¢Ã÷£º ÎÄÕÂתÔØ×Ô£º°®Ë¼×ÊÔ´Íø http://www.aseoe.com/show-12-468-1.html

[Ç°¶Ë²å¼þÍƼö] Plugin

1 2 3 4
  • jQueryʵÏÖÖð×ÖÖð¾äÏÔʾ²å¼þl-by-l.min.js
  • jQuery´ø·½Ïò¸ÐÖªµÄÊó±ê»¬¹ýͼƬ±ß¿òÌØЧ²å¼þ
  • jQuery HotKeys¼àÌý¼üÅÌ°´ÏÂʼþkeydown²å¼þ
  • ÏìӦʽÎÞÏÞÂÖ²¥jQueryÐýתľÂí²å¼þ
ÏìӦʽÎÞÏÞÂÖ²¥jQueryÐýתľÂí²å¼þ
webÇ°¶Ë¿ª·¢
°®Ë¼×ÊÔ´Íø Copyright 2012-2014 Www.Aseoe.Com All rights reserved.(½úICP±¸13001436ºÅ-1)