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.

  • 另一方面,101102只能发出GET和POST请求.如果你不知道这些是什么,你应该判断HTTP protocol并学习一些.在内部,这两个函数使用jQuery.ajax,但它们使用特定的设置,您无需自行设置,因此与使用jQuery.ajax相比简化了GET或POST请求.GET和POST是最常用的HTTP方法(与DELETE、PUT、HEAD甚至其他很少使用的外来方法相比).

所有jQuery函数都在后台使用XMLHttpRequest对象,但提供了不需要自己完成的附加功能.

Usage

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.

Jquery相关问答推荐

逐个交换图像

子 li 元素的点击事件

如何在 jQuery 中使用:not 和 hasClass() 来获取没有类的特定元素

提高 jQuery Select 器性能的好方法?

在范围内设置文本

jquery清除输入默认值

如何计算具有相同类的元素数量?

jQuery 插入 div 作为某个索引

实用的 javascript 面向对象设计模式示例

使用 JavaScript 和 jQuery,跨浏览器处理按键事件 (F1-F12)

将返回的 JSON 对象属性转换为(较低的第一个)camelCase

字符串化(转换为 JSON)具有循环引用的 JavaScript 对象

使用 jQuery Select 最后 5 个元素

jQuery.extend 和 jQuery.fn.extend 的区别?

如何通过js打开 Select 文件对话框?

判断复选框是否未选中单击 - jQuery

如何在 JavaScript 中的对象数组中查找值?

只绑定一次事件

将多个参数传递给 jQuery ajax 调用

jQuery 使用 AND 和 OR 运算符按属性 Select