Last active
December 12, 2015 02:38
-
-
Save tayler/4699834 to your computer and use it in GitHub Desktop.
standard ajax post with jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.jqapi.com/#p=jQuery.ajax | |
var email = $("input#email").val(); | |
var user = $("input#user").val(); | |
var pass = $("input#pass").val(); | |
var dataToSend = { | |
email: email, | |
username: user, | |
password: pass | |
} | |
$.ajax({ | |
url: 'http://location.of.the/file/that/accepts/this/data.php', | |
data: dataToSend, // what you want to send | |
type: 'POST', // how you want to send it; POST is for sending data to the server, GET is for GETting. (there are others) | |
success: function(dataRecievedFromServer) { | |
// you've received a response from the server | |
$("div#successMsg").html("Your account was created"); | |
// do something with dataReceivedFromServer, if necessary | |
}, | |
error: function(error) { | |
console.log(error); | |
// or tell user the submission was unsuccessful | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment