SyntaxStudy
Sign Up
Home jQuery Reference $.get() / $.post()

$.get() / $.post()

method

Shorthand methods for common GET and POST AJAX requests.

Syntax

$.get(url, data, callback) $.post(url, data, callback)

Example

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

// GET with parameters
$.get('/api/search', { q: 'php', page: 1 }, function(results) {
    renderResults(results);
});

// POST request
$.post('/api/subscribe', { email: 'alice@example.com' }, function(res) {
    alert('Subscribed!');
});