This is the jquery code in ColdFusion index.cfm which is calling chkUsername of cfc file.
<script type="text/javascript">
chkUsernameUnique = function(theUsername){
$.getJSON("selectuser.cfc", {
method: 'chkUsername',
Username: theUsername,
returnformat: 'json'
}, function(isUsernameUnique){
if (isUsernameUnique == true) {
$("#theErrorDivID").html('Username is unique');
}
else {
$("#theErrorDivID").html('Please select a new username');
}
});
};
</script>
This is my component which is getting called from the cfm file.
<cfcomponent>
<cffunction name="chkUsername" returnformat="json" output="false">
<cfargument name="username" required="true">
<cfquery name="chkUsername" datasource="myDataSource">
SELECT ID FROM employees_login WHERE username = <cfqueryparam value="#arguments.username#" cfsqltype="cf_sql_varchar" />
</cfquery>
<cfreturn yesNoFormat(chkUsername.recordCount) />
</cffunction>
</cfcomponent>
Nothing was getting displayed. I tried to check the error on fire bug and i am getting this error -
"NetworkError: 500 Internal Server Error:http://localhost:8500/workspace/UniqueUsername/selectuser.cfc?method=chkUsername&Username=admin&returnformat=json"