There is no jQuery way or JavaScript. jQuery is JavaScript. JavaScript is a language, and jQuery is a library of functions written and used with JavaScript. I'm not sure what you mean by JASON (I think you mean JSON) if you don't mean JSONP.
Ajax calls are usually made with an XMLHttpRequest
object - at least for now. IE6 and other older browsers may support ajax using other methods such as ActiveX, and even older browsers may not support it at all.
$.ajax
, the central jQuery ajax method does a lot of work, and you can see what it is , but you cannot understand it. Important line:
jQuery.ajaxSettings.xhr = function() { try { return new XMLHttpRequest(); } catch( e ) {} };
Later we see xhr = options.xhr()
, and then xhr.send
. This is the code you would use to create an ajax request using JavaScript without using jQuery.
$.ajax
also does many other things, since it can handle JSONP (which does not use XMLHttpRequest) transparently, as well as a ton of other things, such as supporting various options, setting headers using different methods, etc. $.ajax
or the jQuery method is just a wrapper for what you think is a JavaScript method.
source share