SyntaxStudy
Sign Up

$.ajax()

method

Performs an asynchronous HTTP request. The low-level foundation for all jQuery AJAX methods.

Syntax

$.ajax({ url, method, data, success, error })

Example

javascript
$.ajax({
    url: '/api/users',
    method: 'POST',
    contentType: 'application/json',
    data: JSON.stringify({ name: 'Alice', email: 'alice@example.com' }),
    success: function(response) {
        console.log('Created:', response);
    },
    error: function(xhr, status, error) {
        console.error('Error:', error);
    }
});