Skip to content

Instantly share code, notes, and snippets.

@brunojppb
Created December 16, 2016 16:58
Show Gist options
  • Save brunojppb/9ff727ee072f68ae4ccefc1e41228dd3 to your computer and use it in GitHub Desktop.
Save brunojppb/9ff727ee072f68ae4ccefc1e41228dd3 to your computer and use it in GitHub Desktop.
$(function() {
$('#id-do-form').submit(function() {
var valuesToSubmit = $(this).serialize();
$.ajax({
type: "POST",
url: $(this).attr('action'), //sumbits it to the given url of the form
data: valuesToSubmit,
dataType: "JSON" // you want a difference between normal and ajax-calls, and json is standard
}).success(function(json){
console.log("success", json);
});
return false; // prevents normal behaviour
});
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment