How to make http request in javascript

What you will learn here about making HTTP request from javascript

  • How to make HTTP request in javascript
    • jquery GET request from javascript
    • jquery POST request from javascript

The easiest way to make HTTP requests to server from javascript is to use jquery. jquery allows users to make HTTP requests from javascript. Here we will see how to make GET and POST request from javascript using jquery.

Please click on following to link to download the code
Download code to make http request from javascript (516 downloads)

Please make sure that you are making the HTTP request to valid URL

jquery GET request from javascript

Please follow the following steps to know how to make HTTP get a request from javascript using jquery.

1)Assuming you have downloaded above codes

2)Unzip the downloaded code

3)In the downloaded code open Get.html file with any editor. The downloaded Get.html file is responsible for making get a request from the javascript to the respective controller which is running on the server. For understanding the code please see the following image.
How to make HTTP request in javascript

4)Here I have uploaded the Get.html file on my local server. Here when user click on Submit button one HTTP GET request is made javascript to user controller which is running on my local server which is shown below
jquery GET request from javascript

5)The response sent by the server is shown below
make http request from jquery

jquery POST request from javascript

Please follow the following steps to know how to make an HTTP post request from javascript using jquery

1)Please use downloaded post.html file to make an HTTP post request from javascript

2)For the understanding of code please see the following image

jquery POST request from javascript

You may also like...

Leave a Reply