Skip to content

Instantly share code, notes, and snippets.

@ryerh
Created May 3, 2018 07:39
Show Gist options
  • Save ryerh/6ba69dce1e0f62ff2756a1ba67e07b17 to your computer and use it in GitHub Desktop.
Save ryerh/6ba69dce1e0f62ff2756a1ba67e07b17 to your computer and use it in GitHub Desktop.
jQuery ajax
import jQuery from 'jquery';
jQuery.ajax({
type: 'POST',
url: 'https://api.github.com',
contentType: 'application/json; charset=UTF-8',
processData: false,
data: JSON.stringify({ foo: 'bar' }),
dataType: 'json', // res data type
// events
beforeSend: (jqXHR, settings) => {},
success: (data, textStatus, jqXHR) => {},
error: (jqXHR, textStatus, errorThrown) => {},
complete: (jqXHR, textStatus) => {},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment