首 页
|
新闻资讯
|
视频教程
|
电脑入门
|
程序开发
|
网页制作
|
操作系统
|
设计在线
|
办公软件
|
网络安全
|
常用软件
|
认证考试
jQuery教程:函数学习之七Ajax部分
[code]函数:$.ajax(properties) 功能:用一个http请求访问一个远程页面 返回:XMLHttpRequest 参数; (String)url请求地址, (String)type请求类型("GET","POST") (String)dataType:从服务器端返回的数据类型("xml","html","script","json") (Boolean)ifModified:根据Last-Modified header判断返回内容是否改变 (Number)timeout:请求超时 (Boolean)global:对此次请求是否引起全局的ajax事件出来,默认true (Function)error:错误处理函数 (Function)complete:请求完成后的处理函数 (Object|String)data:发送到服务器端的数据 (String) contentType :默认"application/x-www-form-urlencoded" (Boolean) processData :传输到服务器端的数据默认被转换到query string中以适合默认"application/x-www-form-urlencoded" 方式,如果你想以DOMDocuments方式传输数据,就将该选项设为false (Boolean)aysnc:是否异步传输,默认为true (Function)beforeSend:请求前响应函数 例子: Load and execute a JavaScript file. jQuery Code $.ajax({ type: "GET", url: "test.js", dataType: "script" }) Save some data to the server and notify the user once its complete. jQuery Code $.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston", success: function(msg){ alert( "Data Saved: " + msg ); } }); jQuery Code var html = $.ajax({ url: "some.php", async: false }).responseText; jQuery Code var xmlDocument = [create xml document]; $.ajax({ url: "page.php", processData: false, data: xmlDocument, success: handleResponse });[/code] [code]函数:$.ajaxSetup(settings),$.ajaxTimeout(time) 功能:设定请求的一些参数 返回:undefined 例子: $.ajaxSetup( { url: "/xmlhttp/", global: false, type: "POST" } ); $.ajaxTimeout( 5000 );[/code] [code]函数:$.get(url, params, callback),$.getIfModified(url, params, callback), $.getJSON(url, params, callback),$.getScript(url, callback) 功能:get方式提交数据 例子: $.get("test.cgi", { name: "John", time: "2pm" }, function(data){ alert("Data Loaded: " + data); } );[/code] [code]函数:$.post(url, params, callback) 功能:post方式提交数据 例子: $.post("test.cgi", { name: "John", time: "2pm" }, function(data){ alert("Data Loaded: " + data); } );[/code] [code]函数:ajaxComplete(callback),ajaxComplete(callback),ajaxSend(callback) ajaxStart(callback),ajaxStop(callback),ajaxSuccess(callback) 功能:XMLHttpRequest状态改变过程中各个响应处理函数 例子: $("#msg").ajaxComplete(function(request, settings){ $(this).append("
Request Complete.
"); }); $("#msg").ajaxSuccess(function(request, settings){ $(this).append("
Successful Request!
"); }); $("#loading").ajaxStop(function(){ $(this).hide(); }); $("#msg").ajaxSend(function(request, settings){ $(this).append("
Starting request at " + settings.url + "
"); });[/code] [code]函数:load(url, params, callback),loadIfModified(url, params, callback) 功能:加载html内容 返回:jQuery对象 参数:同get和post方式提交 例子: jQuery Code $("#feeds").load("feeds.html"); Before
Result:
45
feeds found.
jQuery Code $("#feeds").load("feeds.html", {limit: 25}, function() { alert("The last 25 entries in the feed have been loaded"); }[/code] [code]函数:serialize() 功能:将表单元素和值序列化成string 返回:String 例子: jQuery Code $("input[@type=text]").serialize(); Before
阅读全文:http://x8.MaiCoo.com/tech/javascript/18210.html
发表时间:2008-8-19 9:00:13 讨论数:0
暂无讨论组成员发表!
昵 称
:麦客网友[游客] 如果您不想匿名评论请先
登录
或
注册
!
评 论
:请自觉遵守互联网相关政策法规,管理员有权删除恶意评论、广告和违禁词语。
验证码:
热门讨论文章
1170次
一步一步教你如何重装XP系统(超详细)
122次
Windows XP系统重装详细视频教程
58次
vb.net基础教程
49次
Visual Basic 6.0(VB)入门到精通视频教程
22次
ASP与数据库连接方法
21次
Photoshop精细磨皮去斑教程
20次
Photoshop制作“红心中国”QQ头像
19次
Windows操作系统太慢 重装不如更换帐户
16次
vb. net介绍
13次
Photoshop移花接木:照片换脸术
Copyright © 2008
MaiCoo.Com
All Rights Reserved
浙ICP备06017818号