Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Basic $.ajax() call $.ajax({ url : '/api/users', method : 'GET', success: function (data) { console.log('Users:', data); }, error : function (xhr, status, err) { console.error('Error:', err); } }); // Promise-style chaining $.ajax({ url: '/api/posts', method: 'GET' }) .done(function (data) { renderPosts(data); }) .fail(function (xhr) { showError(xhr.status); }) .always(function () { hideSpinner(); });
Result
Open