jquery的ajax中的几种状态
来源:互联网 发布:java中变量的定义方法 编辑:程序博客网 时间:2024/05/01 12:43
xml文件
myfile.xml
<?xml version="1.0" encoding="utf-8" ?>
<List>
<CB cname="北京" cid="1">
<CS cname="北京" cid="364">北京市</CS>
</CB>
<CB cname="天津" cid="2">
<CS cname="天津" cid="365">天津市</CS>
</CB>
<CB cname="上海" cid="3">
<CS cname="上海" cid="364">上海市</CS>
</CB>
<CB cname="重庆" cid="4">
<CS cname="重庆" cid="365">重庆市</CS>
</CB>
</List>
*********************************************************
展示页面xml.php
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>xml运用</title>
<script language="javascript" src="jquery.js"></script>
<script language="javascript">
$(document).ready(function(){
$("button").click(function(){
$.ajax({
type:"post",
url:"myfile.xml",
dataType:"xml",
error:function(){
alert("有错误!");
},
success:function(xml){
$(xml).find("CB").each(function(){
var cs = $(this).find("CS").text();
alert($(this).find("CS").attr("cname"));
$("#show").append("<font color=maroon>" + cs + "</font><hr />");
});
}
});
});
$("#show").ajaxStart(function(){
$(this).append("<font color=red>1、准备开始</font>");
});
$("#show").ajaxSend(function(){
$(this).append("<font color=red>2、开始发送</font>");
});
$("#show").ajaxSuccess(function(){
$(this).append("<font color=red>3、传送成功</font>");
});
$("#show").ajaxComplete(function(){
$(this).append("<font color=red>4、传送完成</font>");
});
$("#show").ajaxStop(function(){
$(this).append("<font color=red>5、传送停止</font>");
});
$("#show").ajaxError(function(){
$(this).append("<font color=red>传送失败</font>");
});
});
</script>
</head>
<body>
<button onclick="startajax();">开始ajax</button>
<div id="show"></div>
</body>
</html>
//注意:ajaxSend,ajaxStart等都是全局事件,放到其他事件外才能正确显示,否则只能运行ajaxSuccess,ajaxComplete,ajaxStop
myfile.xml
<?xml version="1.0" encoding="utf-8" ?>
<List>
<CB cname="北京" cid="1">
<CS cname="北京" cid="364">北京市</CS>
</CB>
<CB cname="天津" cid="2">
<CS cname="天津" cid="365">天津市</CS>
</CB>
<CB cname="上海" cid="3">
<CS cname="上海" cid="364">上海市</CS>
</CB>
<CB cname="重庆" cid="4">
<CS cname="重庆" cid="365">重庆市</CS>
</CB>
</List>
*********************************************************
展示页面xml.php
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>xml运用</title>
<script language="javascript" src="jquery.js"></script>
<script language="javascript">
$(document).ready(function(){
$("button").click(function(){
$.ajax({
type:"post",
url:"myfile.xml",
dataType:"xml",
error:function(){
alert("有错误!");
},
success:function(xml){
$(xml).find("CB").each(function(){
var cs = $(this).find("CS").text();
alert($(this).find("CS").attr("cname"));
$("#show").append("<font color=maroon>" + cs + "</font><hr />");
});
}
});
});
$("#show").ajaxStart(function(){
$(this).append("<font color=red>1、准备开始</font>");
});
$("#show").ajaxSend(function(){
$(this).append("<font color=red>2、开始发送</font>");
});
$("#show").ajaxSuccess(function(){
$(this).append("<font color=red>3、传送成功</font>");
});
$("#show").ajaxComplete(function(){
$(this).append("<font color=red>4、传送完成</font>");
});
$("#show").ajaxStop(function(){
$(this).append("<font color=red>5、传送停止</font>");
});
$("#show").ajaxError(function(){
$(this).append("<font color=red>传送失败</font>");
});
});
</script>
</head>
<body>
<button onclick="startajax();">开始ajax</button>
<div id="show"></div>
</body>
</html>
//注意:ajaxSend,ajaxStart等都是全局事件,放到其他事件外才能正确显示,否则只能运行ajaxSuccess,ajaxComplete,ajaxStop
- jquery的ajax中的几种状态
- jQuery中的Ajax几种请求方法
- jQuery中的Ajax几种请求方法
- jQuery中的Ajax几种请求方法
- jQuery中的Ajax几种请求方法
- jquery中的几种Ajax应用
- jQuery中的Ajax几种请求方法
- jQuery中的Ajax几种请求方法
- jquery中的ajax几种请求方法
- jquery的几种ajax方式对比
- jquery的几种异步请求,ajax
- jquery的几种异步请求,ajax
- jquery的几种异步请求,ajax
- jquery的几种异步请求,ajax
- jquery的几种ajax方式对比
- jquery的几种ajax方式对比
- jquery的几种ajax方式
- jquery的几种ajax方式
- 笔记本电脑忘记开机密码怎么办?
- 学习日志—序
- 使用jquery点击换图片
- 使用jquery的ajax取xml
- MFC画坐标曲线图(转)
- jquery的ajax中的几种状态
- copy constructor
- 轻松实现asp.net中遍历cookies,session,application,小总结
- 于丹教授携论语带来的感悟
- 使用jquery完成自动隐藏到边框
- 网页标题闪烁
- 时间强烈不够用
- 写function自定义函数时使用jquery
- 画坐标图及曲线