Created
October 30, 2013 10:57
-
-
Save perminder-klair/7230724 to your computer and use it in GitHub Desktop.
Post Json data to PHP using jquer ajax
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
var data = {"data1": "val1", "data2": "val2", "data3": "val3"}; | |
var dataEncoded = JSON.stringify(data); | |
$.ajax({ | |
type: "POST", | |
url: "post-data.php", | |
// The key needs to match your method's input parameter (case-sensitive). | |
data:{"data":dataEncoded}, | |
dataType: "json", | |
success: function(data){ | |
alert(data); | |
}, | |
failure: function(errMsg) { | |
alert(errMsg); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment