久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      ajax如何取php頁面的數(shù)據(jù)

      ajax如何取php頁面的數(shù)據(jù)

      現(xiàn)在經(jīng)常使用Ajax調(diào)用后臺php獲取后臺數(shù)據(jù),下面我們來看一下ajax如何取php頁面的數(shù)據(jù)。

      推薦:php服務器

      1、php連接數(shù)據(jù)庫獲取數(shù)據(jù)庫的信息放入json_encode($css);{文件為:db.php}

      <span style="font-size:14px;"><?php $host="localhost"; $username="root"; $password="root"; $dbName="baixing"; $port=3306; $conn=new mysqli($host,$username,$password,$dbName,$port); if(!$conn){  die("error:".$conn->connect_error); } //設置查詢結(jié)果的編碼,一定要放在query之前 $conn->query("SET NAMES 'UTF8'"); $result=$conn->query("select * from hotgoods"); //$conn->query()獲取的是二進制 //將查詢的結(jié)果集封裝到一個數(shù)組里 $css=$result->fetch_all(); //以json的格式發(fā)送ajax的success中由data接收 echo json_encode($css); $conn->close();</span>

      2、將json_encode($css)的數(shù)據(jù)放在success:function(data)中,如下:{baixing.html}

      $.ajax({   type: 'POST',   url: 'db.php',   data:{ //   "username":"admin", //   "password":"123456"   },   success: function (data) {    var result=eval("("+data+")");    alert(result);    for(var i=0;i<result.length;i++){     var str='<div class="home1">'+       '<img src="'+result[i][1]+'" alt="'+result[i][3]+'"/>'+       '<p><a href="'+result[i][2]+'" rel="external nofollow" rel="external nofollow" >'+result[i][3]+'</a></p>'+       '<div class="price">'+       '<span>¥'+result[i][4]+'</span>'+       '<del>¥'+result[i][5]+'</del>'+       ' <a href="#" rel="external nofollow" rel="external nofollow" >預定:<b>'+result[i][6]+'</b>件</a>'     '</div> </div>'     $(".box7 #hotSale").append(str);//追加到你需要放在的位置    }   }  });$.ajax({   type: 'POST',   url: 'db.php',   data:{ //   "username":"admin", //   "password":"123456"   },   success: function (data) {    var result=eval("("+data+")");    alert(result);    for(var i=0;i<result.length;i++){     var str='<div class="home1">'+       '<img src="'+result[i][1]+'" alt="'+result[i][3]+'"/>'+       '<p><a href="'+result[i][2]+'" rel="external nofollow" rel="external nofollow" >'+result[i][3]+'</a></p>'+       '<div class="price">'+       '<span>¥'+result[i][4]+'</span>'+       '<del>¥'+result[i][5]+'</del>'+       ' <a href="#" rel="external nofollow" rel="external nofollow" >預定:<b>'+result[i][6]+'</b>件</a>'     '</div> </div>'     $(".box7 #hotSale").append(str);    }   }  });

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號