Skip to content

Instantly share code, notes, and snippets.

@wellercs
Created April 6, 2013 21:47
Show Gist options
  • 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