想在本地獲取一下php資源,所以就安裝了wampServer,在www文件下創(chuàng)建了自己的項目打開后就可以進入index.html文件,在index.html中,我使用了ajax想要獲取data1.php中的中的數(shù)據(jù) $.ajax({ url:"data1.php", dataType:'jsonp', type:'get', success:function(data){ console.log(data) }, error:function(XMLHttpRequest, textStatus, errorThrown) { console.log("失敗"); }}); php如下;<?phpheader("Content-type: text/html; charset=utf-8"); header("Access-Control-Allow-Origin: *"); echo "記事本","<br/>";?> 但是在控制臺中報錯為在network中是返回了數(shù)據(jù)的,但是不能在ajax中的data中獲取,并且fail請問如何才能正確獲取php中的數(shù)據(jù)呢?
使用wampServer時,通過ajax無法獲取php文件
搖曳的薔薇
2019-03-12 13:15:43