久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      PHP怎么返回一個(gè)數(shù)據(jù)給前臺(tái)

      PHP怎么返回一個(gè)數(shù)據(jù)給前臺(tái)

      PHP怎么返回一個(gè)數(shù)據(jù)給前臺(tái)

      1、前端通過ajax請(qǐng)求后臺(tái)接口獲取數(shù)據(jù)

      注:需要在這段代碼之前引入jQuery.js庫

      $.ajax({         type: 'POST',         url: 'db.php',         data:{         },         success: function (data) {             alert(data);             }         } });

      2、后臺(tái)php查詢后通過json_encode()轉(zhuǎn)為json數(shù)據(jù)格式返回給前端

      <?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); } //設(shè)置查詢結(jié)果的編碼,一定要放在query之前 $conn->query("SET NAMES 'UTF8'"); $result=$conn->query("select * from hotgoods"); //$conn->query()獲取的是二進(jìn)制 //將查詢的結(jié)果集封裝到一個(gè)數(shù)組里 $css=$result->fetch_all(); //以json的格式發(fā)送ajax的success中由data接收 echo json_encode($css); $conn->close();

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