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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么用Ajax獲取PHP數(shù)據(jù)的時(shí)候,responseText返回的是整個(gè)PHP代碼?。肯旅媸谴a,求大牛解答

為什么用Ajax獲取PHP數(shù)據(jù)的時(shí)候,responseText返回的是整個(gè)PHP代碼???下面是代碼,求大牛解答

一壺時(shí)光 2018-09-13 14:54:16
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title></title> <script type="text/javascript"></script></head><body> <ul> </ul> <script type="text/javascript"> var xhr = new XMLHttpRequest(); xhr.open("GET","users.php?id=2"); xhr.send(); xhr.onreadystatechange=function(){ if(this.readyState==4){ console.log(this.responseText); } } </script></body></html>//PHP代碼<?phpheader('Content-Type: application/json');$data = array(? array(? ? 'id' => 1,? ? 'name' => '張三',? ? 'age' => 18? ),? array(? ? 'id' => 2,? ? 'name' => '李四',? ? 'age' => 20? ),? array(? ? 'id' => 3,? ? 'name' => '二傻子',? ? 'age' => 18? ),? array(? ? 'id' => 4,? ? 'name' => '三愣子',? ? 'age' => 19? ));if (empty($_GET['id'])) {? $json = json_encode($data);?? echo $json;}?else{?? foreach ($data as $item) {? ? if ($item['id'] != $_GET['id']) continue;? ? $json = json_encode($item);?? ? echo $json;? }}
查看完整描述

4 回答

?
宣言的言

TA貢獻(xiàn)3條經(jīng)驗(yàn) 獲得超1個(gè)贊

你的php沒(méi)有放在php環(huán)境中吧?

查看完整回答
1 反對(duì) 回復(fù) 2018-10-04
?
小吳同志

TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超0個(gè)贊

檢查一下你的網(wǎng)址路徑,我之前就是打開(kāi)的本地路徑,要記得是類似localhost:8081/demo.html這樣子~用到PHP的環(huán)境下

查看完整回答
反對(duì) 回復(fù) 2019-02-02
  • 4 回答
  • 0 關(guān)注
  • 2255 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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