Difference between $.ajax() and $.get() and $.load()
2021-07-03 00:07
标签:default turned hyper hid and com pos over for 转自:Difference between $.ajax() and $.get() and $.load() It should be noted that all More details in the Ajax-documentation of jQuery: http://api.jquery.com/category/ajax/ Difference between $.ajax() and $.get() and $.load() 标签:default turned hyper hid and com pos over for 原文地址:http://www.cnblogs.com/drizzlewithwind/p/7126481.html$.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(...)
$.get()
, $.post()
, .load()
are all just wrappers for $.ajax()
as it‘s called internally.
文章标题:Difference between $.ajax() and $.get() and $.load()
文章链接:http://soscw.com/essay/101026.html