第一次用ajax 這個為什麼查詢不到?

來源:互聯網
上載者:User
有兩個頁面一個是ajax頁面 一個是查資料的頁面 我就是想先把查詢到的資料先alert一下 可是什麼都彈不出來 提示這個錯誤:
XMLHttpRequest cannot load file:///D:/wamp/www/chaxun.php. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https,
是不是資料格式有問題呢 還是哪裡的問題?

第一個頁面
    


第二個頁面
chaxun.php
prepare("select * from user");$stmt->execute();$res=$stmt->fetchall(PDO::FETCH_ASSOC);foreach($res as $v){echo $v['username'];}?>


回複討論(解決方案)

有些瀏覽器要求必須有WEB服務才能訪問某些JS函數,不建伺服器不行。

XMLHttpRequest cannot load file:///D:/wamp/www/chaxun.php. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https,
XMLHttpRequest無法負載檔案:/ / / D /伺服器/網路/ chaxun.php。跨域請求僅支援協議:HTTP,資料,Chrome,Chrome擴充,HTTPS,


請在網站上執行您的程式

XMLHttpRequest cannot load file:///D:/wamp/www/chaxun.php. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https,
XMLHttpRequest無法負載檔案:/ / / D /伺服器/網路/ chaxun.php。跨域請求僅支援協議:HTTP,資料,Chrome,Chrome擴充,HTTPS,


請在網站上執行您的程式


這是什麼意思呢 我就是在wamp環境下啟動並執行

有些瀏覽器要求必須有WEB服務才能訪問某些JS函數,不建伺服器不行。


我就是在wamp環境下啟動並執行啊

你的第一段代碼就不是從伺服器上啟動並執行

你的第一段代碼就不是從伺服器上啟動並執行[/


你的第一段代碼就不是從伺服器上啟動並執行


好的 可以了 謝謝
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.