Copy link to clipboard
Copied
Hello,
I am trying to use the cfselect and bind feature but i keep getting the following error when i run the debugger
window:global: SyntaxError: parseJSON (http://www.domain.com/CFIDE/scripts/ajax/package/cfajax.js, line 803)
info:http: CFC invocation response:
Here is the code that i am using
==================================
root directory/addacount.cfm
==================================
<cfform action="addaccountSubmit.cfm" method="post" name="frmAddAccount">
<table align="center">
<tr>
<td>First Name</td>
<td><cfinput type="text" name="firstname" required="yes" message="Please enter a first name." maxlength="100">
</tr>
<tr>
<td>Last Name</td>
<td><cfinput type="text" name="lastname" required="yes" message="Please enter a last name." maxlength="100">
</tr>
<tr>
<td>Email</td>
<td><cfinput type="text" name="email" required="yes" message="Please enter a valid email address" maxlength="150" validate="email"></td>
</tr>
<tr>
<td>Address</td>
<td><cfinput type="text" name="address" required="no" maxlength="150"></td>
</tr>
<tr>
<td>State</td>
<td>
<cfselect name="state" bind="cfc:cfc.actions.getStates()" bindonload="true"/>
</td>
</tr>
</table>
</cfform>
Also if i try to navigate to the cfc and run the method it runs fine and shows that its getting all the states and putting them into an array
http://www.domain.com/cfc/misc.cfc?method=getStates
Can someone please help me out with this, not sure what i am doing wrong?
Copy link to clipboard
Copied
Finally, i figured out what was causing the issue, don't know why this would be causing the issue though.
In my Application.cfc i have the following code:
<cffunction name="OnRequestStart">
<cfargument name = "request" required="true"/>
<cfif IsDefined("form.logout")>
<cflogout>
</cfif>
<cflogin>
<cfif NOT IsDefined("cflogin")>
<cfinclude template="index.cfm">
<cfabort>
<cfelse>
<cfif cflogin.name IS "" OR cflogin.password IS "">
<cfoutput>
<h2>You must enter text in both the User Name and Password fields.
</h2>
</cfoutput>
<cfinclude template="index.cfm">
<cfabort>
<cfelse>
<cfquery name="loginQuery">
SELECT uid, firstname, lastname, rTrim(type) as UserRolename
FROM tbl_users LEFT OUTER JOIN tbl_roles
On tbl_users.roleid = tbl_roles.roleid
WHERE username = <cfqueryparam cfsqltype="cf_sql_varchar" value="#cflogin.name#">
AND password = <cfqueryparam cfsqltype="cf_sql_varchar" value="#cflogin.password#">
</cfquery>
<cfif loginQuery.UserRoleName NEQ "">
<cfloginuser name="#cflogin.name#" Password = "#cflogin.password#"
roles="#loginQuery.UserRoleName#">
<cfelse>
<cfoutput>
<H2>Your login information is not valid.<br>
Please Try again</H2>
</cfoutput>
<cfinclude template="index.cfm">
<cfabort>
</cfif>
</cfif>
</cfif>
</cflogin>
<cfif GetAuthUser() NEQ "">
<cfoutput>
<form action="main.cfm" method="Post">
<input type="submit" Name="Logout" value="Logout">
</form>
</cfoutput>
</cfif>
</cffunction>
Can someone please explain to me why this code would be causing an issue?