How to use jQuery POST and GET AJAX Methods

The Modern way to work

by stackdeveloping
1 comment 156 views
jQuery POST and GET AJAX Methods


Request how to make API Calls

Hi everyone, today we will post an example of how to send a request to the server via jQuery using methods POST and GET. In this example we have to use jQuery also two types of data, one is JSON data, and another is a PHP file, with some data sorted into array, and then converted into JSON format.
So first all we need to do is to to C:\xampp\htdocs\ and create the back-end directory and then from desktop directory we will make the request. As I’m checking until now the Old school tutorials use the CDNS of jQuery or others services PLEASE TRY TO BE MORE MODERN ON DEVELOPING, so it is very easy in that way. Make sure you have installed Node JS to your computer or if you want follow the link to download it Node JS.

So lets create a directory, C:\xampp\htdocs\request and inside this folder we will create two separated directories frontend and backend. From frontend we will make requests API to the backend. And lets sort all the data into a HTML table.

The HTML Structure

<!DOCTYPE html>
  <title>POST and GET Request</title>
  <table id=""></table>
  <script src="node_modules/jquery/dist/jquery.min.js"></script>
     //post request

The formats of both requests should look like below:

$.post("<ulr>",{data:data}, function(response){

Get method in api

$.get("<ulr>",{data:data}, function(response){

In case that we have to request JSON file, its better to call via GET method, because generally JSONs files are mostly PUBLIC data, such as countries data, ips data etc. In case that we want to use the call more securely,  POST its better. On both types we can send data and callback data as response.

Difference between Get and Post

In Get method all parameters and data are sent or requesting to the URL/URI of request. In Post method all parameters and data are sent or requesting to the Body of request.

Get method is more easy accessible, that’s why its used when a service used to provide public data, such as Country List, Name List, planets list, road list etc. Post method its use more security parameters and its  used more to provide to the users generally 3rd party services, premium services that need API keys, Payments methods etc.


JSON file should have this format of data as below:

  "person": {
	   "name": "Michael",
	   "surname": "Idol",
	   "country": "France",
	   "city": "Paris"


You may also like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

1 comment

[email protected] November 5, 2023 - 10:27 am

qui non libero rerum illo sequi ut ut. aut ex odit suscipit nostrum in dolore maxime totam dolorem nemo voluptatibus. reprehenderit facere sit incidunt consequatur. voluptate corporis quas qui culpa e


This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More