Dumbfounded by ajax call of cfc function failure

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()">


	function send() {
		console.log('fn called');
		em = document.getElementById('name').value;
		$.post("./savename.cfc?method=savedata", {dname:'+em+'});


<cfcomponent output="false">

	<cffunction name="savedata" access="remote">
		<cfargument name="dname" type="string" required="yes">
			<cfquery datasource="myds">
				insert into wemail(email)
				values ('#arguments.dname#');			
		<cfcatch type="database">
			<cfset success=0>

direct calling via browser ( test ):‘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.


You are passing the variable em as the string +em+, rather than its value (e.g. “John”).

1 Like

holy molly! Thank you. But then, I shouldn’t get an error, instead, it should have inserted bad data instead. Since I’m getting an error, it seems there’s some syntax error, which one?

You missing a </script> after the jquery.js and a open <script> for the inline-script.

But that also stands in your error message :

Opening and ending tag mismatch
1 Like

Please see above with comments. Thanks.

could you post the error message?