What is the difference between XMLHttpRequest, jQuery.ajax, jQuery.post, jQuery.get

后端 未结 6 1850
无人及你
无人及你 2020-11-29 16:11

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?

6条回答
  •  迷失自我
    2020-11-29 16:39

    As far as the jQuery methods go, .post and .get simply do .ajax internally, their purpose is to abstract away some of the unnecessary options of .ajax and provide some defaults appropriate to that type of request respectively.

    I doubt there's much difference in performance between any of the 3.

    The .ajax method in itself does an XMLHttpRequest, it'll be heavily optimised as per the rest of jQuery, but it probably won't be as efficient as if you tailored the whole interaction yourself.. but that's the difference between writing lots of code or writing jQuery.ajax.

提交回复
热议问题