jquery通過ajax調用php取得返回值,怎么做?
2 回答

森林海
TA貢獻2011條經(jīng)驗 獲得超2個贊
給你一個簡單的返回數(shù)據(jù)代碼
<?php
// 請使用UTF-8編碼,否則會出錯!
$array=array(
"status"=>"200",
"reason"=>"Return Tips",
"result"=>array(
"data1"=>"我是正常返回數(shù)據(jù)1",
"data1"=>"我是正常返回數(shù)據(jù)2"
"get"=>"GET提交數(shù)據(jù)為[".$_GET["data"]."]",
),
"error"=>"我是報錯信息"
);
echo json_encode($array);
?>
// 這里也要用 UTF-8 編碼
$(function(){
$.ajax({
type:"get",
url:"test.php",
success:function(data){
if (data
- 2 回答
- 0 關注
- 2273 瀏覽
添加回答
舉報
0/150
提交
取消