Hackforge Academy

Category: javascript

ajax with jquery

Published on 30 Sep 2026

Explanation

AJAX allows a web page to communicate with the server without performing a full page reload.

Code:

Browser
   |
   | AJAX Request
   v
Server
   |
   | JSON Response
   v
Browser

Explanation

The $.ajax() method provides detailed control over HTTP requests.

Code:

$.ajax({
    url: '/api/users',
    method: 'GET',
    success: function(data) {
        console.log(data);
    }
});

Explanation

The $.get() method provides a shorter way to send a GET request.

Code:

$.get('/api/users', function(data) {
    console.log(data);
});

Explanation

The $.post() method sends data to a server using an HTTP POST request.

Code:

$.post('/api/users', {
    name: 'Praveen',
    email: 'p@example.com'
}, function(response) {
    console.log(response);
});

Explanation

AJAX can send JSON data to a REST API by specifying the content type and converting the object to JSON.

Code:

$.ajax({
    url: '/api/users',
    method: 'POST',
    contentType: 'application/json',
    data: JSON.stringify({
        name: 'Praveen'
    }),
    success: function(response) {
        console.log(response);
    }
});

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community