Copy link to clipboard
Copied
I am attempting to learn Ajax and have come across a problem. I want to submit the form values to a method. The code below succesffully contacts the cfc and the function however the form values are not being passed. I feel like I have tried everything I know to try. I would also like to inquire about a good place or good book to really learn Ajax and in particular Coldfusion and Ajax. (book or web site)
<cfajaxproxy bind="cfc:invoice.putItems({Add@click})">
<cfform name="formitems" id="formitems">
<cfinput type="text" name="item1" value="" />
<cfinput type="text" name="item2" value="" />
<cfinput type="button" name="Add" value="Add" id="Add">
</cfform>
Copy link to clipboard
Copied
This is what I use to submit forms via ajax:
<script type="text/javascript">
function updateErrorHandler(id,message) {
alert("Error while updating\n Error code: "+id+"\n Message: "+message);
}
function doInsert(nForm) {
ColdFusion.Ajax.submitForm(nForm, '/doInsert.cfm?method=insertData', resultInsertHandler, insertErrorHandler, 'POST');
}
function resultInsertHandler(returnMsg) {
var resultDiv = document.getElementById("result");
resultDiv.visibility = 'visible';
resultDiv.innerHTML = '<div>Success!</div>';
resultDiv.visibility = 'visible';
setTimeout("HideOpenMenus()",5000);
}
function insertErrorHandler(id, message) {
alert("Error while updating\n Error code: "+id+"\n Message: "+message);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = "<p>Failed!</p>";
}
</script>
let me know if you have any questions reagarding this