'difference between xmlhttprequest and $.ajax(), $.load
what is actually difference between
xmlhttprequest and $.ajax()
i want to know which is the lightest function from above to load data....
Solution 1:[1]
XMLHttpRequest is the raw ajax request object. Working with this directly would be the 'lightest', but you're losing all the cross browser compatibility provided by the $.ajax() method in JQuery. If you want your code to work across all browsers, you must use $.ajax().
Solution 2:[2]
$.ajax uses an XmlHttpRequest under the hood. See here
You get the benefit of having it all encapsulated away by using $.ajax so I'd use that instead of writing all the cross-browser support yourself
Solution 3:[3]
The jQuery's $.ajax is just a crossbrowser-compatible wrapper around XMLHttpRequest. You don't need to introduce countless nasty if/try blocks to get it to work in any webbrowser the world wide web is aware of. If you're using jQuery, you're supposed to use it (or one of the other Ajax functions).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | hobodave |
| Solution 2 | AdaTheDev |
| Solution 3 | BalusC |
