Skip to content

Instantly share code, notes, and snippets.

@buzzedword buzzedword/ajax-events.js

Last active Dec 13, 2015
What would you like to do?
$("#submit-btn").on('click', function(event) {
var form, url, data, requests;
form = $("#form");
url = form.attr('action');
data = form.serializeArray();
requests = {
getJsonAction : '' // No query param here. jsonp mode sets it.
// The functions which handles success and failure
var responseHandler = {
success: function(data){
console.log('Response was successful.', data);
error: function(data){
console.log('Response issued an error.', data);
// Use raw AJAX for finer control over jqXHR object.
dataType: "jsonp",
url: requests.getJsonAction,
type: 'POST'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.