第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用Jquery Ajax從Mysql中檢索數(shù)據(jù)

使用Jquery Ajax從Mysql中檢索數(shù)據(jù)

忽然笑 2019-07-30 15:20:26
使用Jquery Ajax從Mysql中檢索數(shù)據(jù)list.php:一個簡單的ajax代碼,我只想顯示Mysql表的記錄:<html><head>     <script src="jquery-1.9.1.min.js">     </script>     <script>     $(document).ready(function() {         var response = '';         $.ajax({             type: "GET",             url: "Records.php",             async: false,             success: function(text) {                 response = text;             }         });         alert(response);     });     </script></head><body>     <div id="div1">         <h2>Let jQuery AJAX Change This Text</h2>     </div>     <button>Get Records</button></body></html>Records.php是從Mysql獲取記錄的文件。在數(shù)據(jù)庫中只有兩個字段:“名稱”,“地址”。<?php    //database name = "simple_ajax"     //table name = "users"     $con = mysql_connect("localhost","root","");     $dbs = mysql_select_db("simple_ajax",$con);     $result= mysql_query("select * from users");     $array = mysql_fetch_row($result);?><tr>     <td>Name: </td>     <td>Address: </td></tr><?php    while ($row = mysql_fetch_array($result))     {         echo "<tr>";         echo "<td>$row[1]</td>";         echo "<td>$row[2]</td>";         echo "</tr>";     }   ?>此代碼無效。
查看完整描述

3 回答

?
aluckdog

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超7個贊

您不能返回ajax返回值。存儲全局變量存儲返回后的返回值。
或者像這樣更改你的代碼。

AjaxGet = function (url) {
    var result = $.ajax({
        type: "POST",
        url: url,
       param: '{}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
       async: false,
        success: function (data) {
            // nothing needed here
      }
    }) .responseText ;
    return  result;}


查看完整回答
反對 回復(fù) 2019-07-30
  • 3 回答
  • 0 關(guān)注
  • 637 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號