慕勒5525576
你看到的不是源码,是php运行结果
慕盖茨3456306
$(function () {
$('#btnShow').ajaxStart(function(){
$(this).html("正在请求数据...");
});
$('#btnShow').ajaxStop(function(){
$(this).html("数据请求完成!");
});
米咔咔
<html xmlns="
<head>
<title>使用ajaxStart()和ajaxStop()方法</title>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="divtest">
<div class="title">
<span class="fl">加载一段文字</span>
<span class="fr">
<input id="btnShow" type="button" value="加载" />
</span>
</div>
<ul>
<li id="divload">111</li>
</ul>
</div>
<script type="text/javascript">
$(function () {
$(document).ajaxStart(function(){
console.log($(this))
$('#divload').html("正在请求数据...");
});
$(document).ajaxStop(function(){
console.log($(this))
$('#divload').html("数据请求完成!");
});
$("#btnShow").bind("click", function () {
var $this = $(this);
$.ajax({
url: "https://www.imooc.com/data/info_f.php",
dataType: "json",
success: function (data) {
$this.attr("disabled", "true");
$("ul").append("<li>我的名字叫:" + data.name + "</li>");
$("ul").append("<li>男朋友对我说:" + data.say + "</li>");
}
});
})
});
</script>
</body>
</html>
慕先生6483341
可以运行的,请确认你写对了。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>使用getJSON()方法异步加载JSON格式数据</title>
<script src="https://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="divtest">
<div class="title">
<span class="fl">我最喜欢的一项运动</span>
<span class="fr">
<input id="btnShow" type="button" value="加载" />
</span>
</div>
<ul></ul>
</div>
<script type="text/javascript">
$(function () {
$("#btnShow").bind("click", function () {
var $this = $(this);
$.getJSON('https://www.imooc.com/data/sport.json', function(data){
$this.attr("disabled", "true");
$.each(data, function (index, sport) {
if(index==3)
$("ul").append("<li>" + sport["name"] + "</li>");
});
});
})
});
</script>
</body>
</html>
Miller_Wang
答:这个.html文件的数据如下,虽然文件后缀是.html,但是文件内容直接就是要加载的元素。
<h3>测试部分</h3> <li>橘子</li> <li>香蕉</li> <li>葡萄</li> <li>苹果</li> <li>西瓜</li>
慕仙621984
都不用这样处理兼容了呢
慕无忌0483822
qq_慕哥5574208
慕虎4537833
:https://www.imooc.com/qadetail/337045
曹蕊
jfhdibrbfjd
weixin_慕先生7001367
慕圣6508991
这个看看文档就会了
Gan干
用IE浏览器打开,不要用谷歌浏览器。
Sukie_
第一个问号是读取email,第二个是修改email,第三个是删除email
Sukie_
你这个用一个比较好的编辑器开发呀,直接就报出来了
Sukie_
换cdn:https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
溯白
首先 你要知道的是:json是在datatype里面设置的。datatype指的是从服务器里面返回数据的类型。所以设置datatype:json ,表达的是返回数据类型为json的数据。然后你看data.name。调用的方式就是根据json类型来使用的。
weixin_慕瓜0263649
<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>使用load()方法异步请求数据</title>
<script src="https://www.imooc.com/static/lib/jquery/1.9.1/jquery.js" type="text/javascript"></script>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="divtest">
<div class="title">
<span class="fl">我最爱吃的水果</span>
<span class="fr">
<input id="btnShow" type="button" value="加载" />
</span>
</div>
<ul><h3></h3></ul>
</div>
<script type="text/javascript">
$(function () {
$("#btnShow").bind("click", function () {
var $this = $(this);
$("ul")
.html("<img src='Images/Loading.gif' alt=''/>")
.load("https://www.imooc.com/data/fruit.html",function(){
$this.attr("disabled", "true");
});
})
});
</script>
</body>
</html>
weixin_慕瓜0263649
回头看我漂亮的坚持
$("#accrodion").accrodion(); 单词拼错了
应该是accordion
程序小白zxcn
重定向
whiteDive
我理解的图片是起到一个万一页面加载很慢,数据未加载成功之前的一个缓和用户心情的作用,就是你去餐馆点菜后,等待上菜的那段时间里餐馆提供的蟹片,如果上菜事件超级快,就像程序加载那样瞬间完成,很显然,蟹片是你视觉不能察觉到它的存在的
whiteDive
这里给提供了php文件
qq_清风扶月_0
把jquery 文件的http改成 https
慕粉3805859
node_b那个用id来获取可以实现
慕丝01
页面上所有的http修改成https,目前全面https了,说明这教程有点老了
慕丝01
Apache服务器运行了吗?
慕先生9164688
上面这段代码我这里看显示正常啊
慕先生9164688
跨域得问题 你所设置得URL 与你本地得服务器 由于同源政策 有跨域问题