Languages
[Edit]
EN

JavaScript - ajax request

1 points
Created by:
Dragontry
731

In this article, we would like to show you how to make AJAX requests in JavaScript.

1. Pure JavaScript (Vanilla JS) AJAX request with XMLHttpRequest object example

Edit

Browser site GET and POST methods example:

SpringMVC server site GET and POST methods example:

Note: run both logics on same server.

Result:

XMLHttpRequest with GET request method usage example run on localhost.
XMLHttpRequest with GET request method usage example run on localhost.

2. jQuery AJAX request example 

Edit

Browser site GET and POST methods example:

SpringMVC server site GET and POST methods example:

Note: run both logics on same server.

Result:

jQuery AJAX GET request method usage example run on localhost.
jQuery AJAX GET request method usage example run on localhost.

3. fetch method example

Edit

Browser site GET and POST methods example:

SpringMVC server site GET and POST methods example:

Note: run both logics on same server.

Result:

GET request method usage example with fetch method run on localhost.
GET request method usage example with fetch method run on localhost.

4. fetch method with ES7 async/await example

Edit

Browser site GET and POST methods example:

SpringMVC server site GET and POST methods example:

Note: run both logics on same server.

Result:

GET request method usage example with fetch method and ES7 async/await run on localhost.
GET request method usage example with fetch method and ES7 async/await run on localhost.

References

Edit
  1. Ajax (programming) - Wikipedia
  2. XMLHttpRequest.prototype.send method - MDN Docs
  3. jQuery.ajax method - jQuery Docs
  4. Using Fetch - MDN Docs

Alternative titles

  1. JavaScript - how to make ajax request?
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join