Code below.
<form action="" method="post">
Enter your name: <input type="text" name="name" id="name"> <input type="button" name="add" value="Go" onclick="send()">
</form>
<script
src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous">
function send() {
console.log('fn called');
em = document.getElementById('name').value;
console.log(em);
$.post("./savename.cfc?method=savedata", {dname:'+em+'});
}
</script>
cfc
<cfcomponent output="false">
<cffunction name="savedata" access="remote">
<cfargument name="dname" type="string" required="yes">
<cftry>
<cfquery datasource="myds">
insert into wemail(email)
values ('#arguments.dname#');
</cfquery>
<cfcatch type="database">
<cfset success=0>
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>
direct calling via browser ( test ):
http://127.0.0.1/myapp/savename.cfc?method=savedata&dname=âJohnâ
Err msg:
### This page contains the following errors:
error on line 16 at column 9: Opening and ending tag mismatch: meta line 0 and head
### Below is a rendering of the page up to the first error.
thanks.