jQuery-ajax-.get,.post方法
来源:互联网 发布:微博情感分析数据集 编辑:程序博客网 时间:2024/05/16 20:54
在上一篇中详细介绍了jQuery中ajax局部方法$.load()的使用。下面来介绍两个全局方法$.get(),$.post()的使用。
1、这两个全局方法其实和上一篇中的$.load()方法使用是差不多的。只是多了第四个参数接收的数据类型。
<span style="font-size:14px;color:#FF0000;"><script>$(function(){/*//直接请求远程的php文件,是以get形式请求的$("#button").click(function(){$.get('remote.php',function(response, status, xhr){//alert(response);//alert(status);//alert(xhr.statusText);$.each(xhr, function(k, v){$("#box").append(k+'=>'+v+'<br/>');})})})*//*//可以在请求的地址中传入参数,也可以在第三个参数上以字符串的形式传入参数$("#button").click(function(){$.get('remote.php?username=zhangsan','age=89',function(response, status, xhr){alert(response);//alert(status);//alert(xhr.statusText);})})*///可以在请求的地址中传入参数,也可以在第三个参数上以对象的形式传入参数$("#button").click(function(){$.get('remote.php',{age:90,username:"zhangsan"},function(response, status, xhr){alert(response);//alert(status);//alert(xhr.statusText);})})//如果需要返回的内容强制转换为我们所需的内容,可以使用第四个参数来接收返回来的内容。如果不传这个从参数,将会智能识别返回来的内容。最好是使用这个参数/*$("#button").click(function(){$.get('remote.php?username=zhangsan','age=89',function(response, status, xhr){alert(response);//alert(status);//alert(xhr.statusText);},'json')})*/})</script></span>
上面的这些例子详细讲述了$.get()这个方法的使用,$.post()这个方法的使用方法也是和这个方法是一样的,只是http请求的方法不一样。还有传参数不能直接在URL后面直接加参数,但是也是可以在第二个参数中以字符串的形式或者是以对象的形式传参数。
0 0
- jQuery-ajax-.get,.post方法
- jQuery ajax - post() 方法 get()方法区别
- jQuery - AJAX get() 和 post() 方法
- jQuery - AJAX get() 和 post() 方法
- jQuery ajax中的get()与post()方法
- jQuery - AJAX get() 和 post() 方法
- jQuery - AJAX get() 和 post() 方法
- jQuery - AJAX get() 和 post() 方法
- jQuery - AJAX get() 和 post() 方法
- jQuery - AJAX get() 和 post() 方法
- jquery ajax post get
- jQuery $ajax $post $get
- Jquery $.ajax/$.post/$.get
- JQuery 中的ajax的方法 ($.ajax,$.post.$get,$.jgetJSON)
- jQuery教程 - Ajax之$.get()方法和$.post()方法
- jQuery Ajax之$.get()方法和$.post()方法
- JQuery .ajax .post .get 应用
- jQuery $.ajax() $.get() $.post() $.getJSON()
- 优秀程序员必备素质
- 已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。
- pat1090 Highest Price in Supply Chain
- list排序
- ubuntu下用U盘安装grub2制作系统启动U盘锁
- jQuery-ajax-.get,.post方法
- 遗失的JVM堆内存
- jQuery mobile 学习06 提示框和确认框
- c++括号匹配
- Not so Mobile
- Bootstrap学习(一)
- IIS7配置PHP和Imagick
- 获取版本号
- Excel2013下拉菜单怎么做