Skip to content

Instantly share code, notes, and snippets.

@wellercs
Created April 6, 2013 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wellercs/5327749 to your computer and use it in GitHub Desktop.
Save wellercs/5327749 to your computer and use it in GitHub Desktop.
jQuery example of calling a function that consumes Response.cfc
<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