不報(bào)錯(cuò) 也什么都不顯示
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>使用get()GET方式從服務(wù)器獲取數(shù)據(jù)</title>
<script type="text/javascript" src="lib/jquery-3.3.1.min.js">
</script>
</head>
<!--
? ? 使用get()方法時(shí),采用GET方式向服務(wù)器請(qǐng)求數(shù)據(jù),并通過(guò)方法中回調(diào)函數(shù)的參數(shù)返回請(qǐng)求的數(shù)據(jù),
? ? 它的調(diào)用格式如下:
$.get(
? ? "發(fā)送的請(qǐng)求地址" ,
? ? 要發(fā)送的數(shù)據(jù) key/value ,?
回調(diào)函數(shù) ,
"返回內(nèi)容格式,xml, html, script, json, text "
);
? ? -->
<body>
<div>
<div>
<span>我的個(gè)人資料</span>
<span>
<input type="button" value="加載" id='jia' />
</span>
</div>
<ul></ul>
</div>
<script type="text/javascript">
$(function (){
$('#jia').bind('click',function(){
var $this = $(this);
$.get('new_file.php',function(date){
$this.attr('disable','true');
$('ul').append("<li>我的名字叫:"+date.name+"</li>");
$('ul').append("<li>男朋友對(duì)我說(shuō):"+date.say+"</li>");
//返回內(nèi)容格式,xml, html, script, json, text?
},"script");
});
});
</script>
</body>
</html>
info.php文件
<?php
echo json_encode(array("name"=>"土豪","say"=>"咱們交個(gè)朋友吧"));
?>
2018-08-05
new_file.php ???你文中不是這樣:
info.php文件
<?php
echo json_encode(array("name"=>"土豪","say"=>"咱們交個(gè)朋友吧"));
?>
2018-06-01
$.get('new_file.php',function(date){
$this.attr('disable','true');
$('ul').append("<li>我的名字叫:"+date.name+"</li>");
$('ul').append("<li>男朋友對(duì)我說(shuō):"+date.say+"</li>");
//返回內(nèi)容格式,xml, html, script, json, text?
},"script"); ? 加粗部分 只要改成json就不顯示 ?改成其他的 就?undefined