I am testing with a very simple form. I am new to js. The returned data is not outputting to my test alert box. The alert result: it worked [object Object] rather than showing the data in the alert.
The response: {"COLUMNS":["CONTACTID"],"DATA":[[903]]}
My end goal is to populate another form field with the returned contactid.
Any help is appreciated. Thank you.
<!DOCTYPE html>
<html lang="en">
<script>
// wait for the DOM to be loaded
$(document).ready(function() {
// bind 'contactform' and provide a simple callback function
$('#contactform').ajaxForm({
dataType: 'json',
clearForm: true,
success: processJson
});
function processJson(data) {
// 'data' is the json object returned from the server
alert("it worked" + data);
}
});
</script>
<!---Form--->
<form id="contactform" action="cfc/insert.cfc?method=insertcontact" method="post">
First Name: <input type="text" name="firstname" />
Last Name: <input type="text" name="lastname" />
<input id="btnSave" type="submit" value="Submit" />
</form>
</html>