不報錯 也什么都不顯示
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>使用get()GET方式從服務器獲取數據</title>
<script type="text/javascript" src="lib/jquery-3.3.1.min.js">
</script>
</head>
<!--
? ? 使用get()方法時,采用GET方式向服務器請求數據,并通過方法中回調函數的參數返回請求的數據,
? ? 它的調用格式如下:
$.get(
? ? "發送的請求地址" ,
? ? 要發送的數據 key/value ,?
回調函數 ,
"返回內容格式,xml, html, script, json, text "
);
? ? -->
<body>
<div>
<div>
<span>我的個人資料</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>男朋友對我說:"+date.say+"</li>");
//返回內容格式,xml, html, script, json, text?
},"script");
});
});
</script>
</body>
</html>
info.php文件
<?php
echo json_encode(array("name"=>"土豪","say"=>"咱們交個朋友吧"));
?>
2018-08-05
new_file.php ???你文中不是這樣:
info.php文件
<?php
echo json_encode(array("name"=>"土豪","say"=>"咱們交個朋友吧"));
?>
2018-06-01
$.get('new_file.php',function(date){
$this.attr('disable','true');
$('ul').append("<li>我的名字叫:"+date.name+"</li>");
$('ul').append("<li>男朋友對我說:"+date.say+"</li>");
//返回內容格式,xml, html, script, json, text?
},"script"); ? 加粗部分 只要改成json就不顯示 ?改成其他的 就?undefined