Last active
December 25, 2015 18:39
-
-
Save adammcarth/7022335 to your computer and use it in GitHub Desktop.
Working with a json response in jQuery.
This file contains 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
$.ajax({ | |
// blah-blah-blah, | |
success: outputSomething | |
}); | |
function outputSomething(data) { | |
$.each(data.errors, function(field, message) { | |
alert(field); // alert("body"), alert ("name") | |
}) | |
} |
This file contains 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
{ | |
"status": 0, | |
"errors": { | |
"body": "You need to enter a comment!?", | |
"name": "Please enter your name." | |
}, | |
"message": "Your comment failed to submit. Please correct any errors and try again." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment