Difference between $.ajax() and $.get() and $.load()
转自:Difference between $.ajax() and $.get() and $.load()
$.ajax() is the most configurable one, where you get fine grained control over HTTP headers and such. You're also able to get direct access to the XHR-object using this method. Slightly more fine-grained error-handling is also provided. Can therefore be more complicated and often unecessary, but sometimes very useful. You have to deal with the returned data yourself with a callback.
$.get() is just a shorthand for $.ajax() but abstracts some of the configurations away, setting reasonable default values for what it hides from you. Returns the data to a callback. It only allows GET-requests so is accompanied by the $.post() function for similar abstraction, only for POST
.load() is similar to $.get() but adds functionality which allows you to define where in the document the returned data is to be inserted. Therefore really only usable when the call only will result in HTML. It is called slightly differently than the other, global, calls, as it is a method tied to a particular jQuery-wrapped DOM element. Therefore, one would do: $('#divWantingContent').load(...)
It should be noted that all $.get(), $.post(), .load() are all just wrappers for $.ajax() as it's called internally.
More details in the Ajax-documentation of jQuery: http://api.jquery.com/category/ajax/
Difference between $.ajax() and $.get() and $.load()的更多相关文章
- js进阶 14-1 jquery的ajax系列中的load方法的作用是什么
js进阶 14-1 jquery的ajax系列中的load方法的作用是什么 一.总结 一句话总结:jQuery load()方法作用是从服务器加载数据,是一个简单但强大的AJAX方法. 1.load函 ...
- jQuery 学习05——AJAX:定义、load()方法、get()/post()方法
AJAX = 异步 JavaScript 和 XML(Asynchronous JavaScript and XML). load() 方法:从服务器加载数据,并把返回的数据放入被选元素中. 语法:$ ...
- Ajax学习笔记(2)--load()方法
<head runat="server"> <title></title> <script src="http://localh ...
- [Full-stack] 网页布局艺术 - Less
故事背景 一个过程: template/html ----> css ----> less ----> bootstrap/flex ----> Semantic-ui fle ...
- jquery接触初级-----ajax 之:load()方法
jquery _ajax 请求主要有几种方式:load(),$.get(),$.post(),$.ajax(),$.getScript(),$.getJson() 1.load()方法 格式:load ...
- JavaScript权威设计--jQuery,Ajax.animate,SVG(简要学习笔记二十)[完结篇]
1.$和jquery在全局命名空间中定义的唯一两个变量. 2.jquery是工厂函数,不是构造函数.他返回一个新创建的对象. 3.jquery的四种调用方式: <1>传递C ...
- Ajax_04之jQuery中封装的Ajax函数
1.PHP中json_encode编码规则: PHP索引数组编码为JSON:[...] PHP关联数组编码为JSON:{...}2.jQuery中AJAX封装函数之load: ①使用:$('选择器') ...
- 从 AJAX 到 JSONP的基础学习
目录索引: 一.AJAX的概念二.POST && GET三.原生实现AJAX简单示例 3.1 实现代码 3.2 重点说明四.框架隐藏域 4.1 基本概念 4.2 后台写入脚本 4.3 ...
- JQuery的ajax
JQuery-AJAX: jQuery load() 方法是简单但强大的 AJAX 方法. $(selector).load(URL,data,callback);(这三个参数可以随意设置几个) @ ...
随机推荐
- WPF定时刷新UI界面
代码: using NHibernate.Criterion; using System; using System.Collections.Generic; using System.Collect ...
- 域名通过infopath访问webservice出现401错误
解决办法: 跟服务器有关,需要再每台服务器进行以下配置 New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name " ...
- 比特币的TxHash为什么会发生改变
比特币中TxHash为什么会变化? 一直不理解比特币的Tx在被打包确认之前TxHash为什么会发生变化,这次终于找到了依据. 交易可延展性 虽然交易签名后,签名当前不会覆盖经过哈希处理以创建事务哈希的 ...
- HTML5 SSE 数据推送应用开发
javascript表达行为,css表达外观,注意HTML既表达结构(逻辑结构),又表达内容(数据本身)通常需要更新数据时,并不需要更新结构,正是这种不改变组织结构仅改变数据的诉求,推动了数据拉取和数 ...
- 对this的理解?
回答一: (1) Js的this指向是不确定的,也就是说可以动态改变的.Call/apply 就是用于改变this指向的函数,这样设计可以让代码更加灵活,复用性更高 (2) This一般情况下,都是指 ...
- PHP中php_sapi_name()与array_map()
1,php_sapi_name() php_sapi_name返回web服务器和php之间的接口类型.函数说明: string php_sapi_name(void) 返回描述php所使用的接口类型的 ...
- 记一次在CentOS系统搭建python3环境
首先,查看linux系统类型和版本:参考:查看linux系统类型和版本 默认Centos7中是有python安装的,但是是2.7版本,实际上这几个文件之间是有依赖关系的.在ls 后面加个 -al参数, ...
- Ionic2 自学须知的基本知识点
http://www.cnblogs.com/zsl123/p/5991336.html Ionic(ionicframework)一款接近原生的HTML5移动App开发框架. IONIC 是目前最有 ...
- 火焰图定位dbproxy问题
https://blog.csdn.net/oujiangping/article/details/78580450 https://blog.csdn.net/gatieme/article/det ...
- P3292 [SCOI2016]幸运数字
题目链接 题意分析 一句话题意 : 树上一条链中挑选出某些数 异或和最大 我们可以考虑维护一个树上倍增线性基 然后倍增的时候 维护一个线性基合并就可以了 写起来还是比较容易的 CODE: #inclu ...