Are jQuery.ajax and $ .ajax the same?

In tutorials you can see jQuery.ajax and $ .ajax

Like here http://www.thekludge.com/form-auto-save-with-jquery-serialize/

jQuery.ajax({ url: 'my_form.php', 

And here http://www.yourinspirationweb.com/en/how-and-when-to-use-jquerys-serialize-method/

 $.ajax({ url: 'elaboration.php', 

Please advice: jQuery.ajax and $ .ajax are the same?

+4
source share
4 answers

In general, they may not be the same.

$ can be used and rewritten by another library that uses it as a global reference to itself.

+1
source

According to the jQuery documentation ,

The sample code on this page is written as:

 $.ajax({ url: "test.html", context: document.body }).done(function() { $(this).addClass("done"); }); 

so yes, they must be the same.

+1
source

jQuery.ajax and $.ajax are the same thing. The dollar sign is an alias for jQuery functions. In some cases, when other js files use a dollar sign, you need to use jQuery . Otherwise, the selector will be ambiguous and errors will be sent to the console.

0
source

Yes, they are the same. See the docs for more details:

http://api.jquery.com/jQuery/

Some libraries, such as the prototype, also use $ for their own purposes. jQuery can be put into noconflict mode to handle situations where you have another library on the same page that also uses $ . In this case, they will be different.

0
source

Source: https://habr.com/ru/post/1479855/


All Articles