为了账号安全,请及时绑定邮箱和手机立即绑定

不报错 也什么都不显示

<!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"=>"咱们交个朋友吧"));

?>


正在回答

2 回答

new_file.php ???你文中不是这样:

info.php文件


<?php

echo json_encode(array("name"=>"土豪","say"=>"咱们交个朋友吧"));

?>


0 回复 有任何疑惑可以回复我~

$.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


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
jQuery基础(五)一Ajax应用与常用插件
  • 参与学习       69095    人
  • 解答问题       400    个

如何用jquery实现ajax应用,加入学习,有效提高前端开发速度

进入课程

不报错 也什么都不显示

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信