Created
April 6, 2013 21:47
-
-
Save wellercs/5327749 to your computer and use it in GitHub Desktop.
jQuery example of calling a function that consumes Response.cfc
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
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$.ajax({ | |
url: '/sandbox/Demo.cfc', // this can be found at https://gist.github.com/wellercs/5327556 | |
data: { | |
method: 'validateDemo', | |
fname: "John", | |
lname: "Doe", | |
email: "bademail", | |
returnFormat: "json" | |
}, | |
dataType: "json", | |
complete: function(XMLHttpRequest, textStatus) { | |
var jsonResponse = $.parseJSON(XMLHttpRequest.responseText); | |
console.log(jsonResponse); | |
if (jsonResponse.SUCCESS) { | |
console.log("success"); | |
} else { | |
console.log(jsonResponse.ERRORS); | |
} | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment