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

后端 未结 6 1851
无人及你
无人及你 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:44

    Each one of them uses XMLHttpRequest. This is what the browser uses to make the request. jQuery is just a JavaScript library and the $.ajax method is used to make a XMLHttpRequest.

    $.post and $.get are just shorthand versions of $.ajax. They do pretty much the same thing but makes it quicker to write an AJAX request - $.post makes a HTTP POST request and $.get makes a HTTP GET request.

提交回复
热议问题