How can I find out which method is best for a situation? Can anybody provide some examples to know the difference in terms of functionality and performance?
How can I find out which method is best for a situation? Can anybody provide some examples to know the difference in terms of functionality and performance?
100是原始浏览器对象,jQuery将其包装成更可用、更简化的形式,并提供跨浏览器一致的功能.
jQuery.ajax
is a general Ajax requester in jQuery that can do any type and content requests.
另一方面,101和102只能发出GET和POST请求.如果你不知道这些是什么,你应该判断HTTP protocol并学习一些.在内部,这两个函数使用jQuery.ajax
,但它们使用特定的设置,您无需自行设置,因此与使用jQuery.ajax
相比简化了GET或POST请求.GET和POST是最常用的HTTP方法(与DELETE、PUT、HEAD甚至其他很少使用的外来方法相比).
所有jQuery函数都在后台使用XMLHttpRequest
对象,但提供了不需要自己完成的附加功能.
So if you're using jQuery I strongly recommend that you use jQuery functionality only. Forget about XMLHttpRequest
altogether. Use suitable jQuery request function variations and in all other cases use $.ajax()
. So don't forget there are other common jQuery Ajax related functions to $.get()
, $.post()
and $.ajax()
. Well you can just use $.ajax()
for all of your request, but you will have to write a little more code, because it needs a bit more options to call it.
It's like you would be able to buy yourself a car engine that you'd have to create a whole car around it with steering, brakes etc... Car manufacturers produce completed cars, with a friendly interface (pedals, steering wheel etc.) so you don't have to do it all yourself.