House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

JSON object error

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
sandeep saini
03/12/2010 04:30 PM

guys, I am getting following error when i access a CFC from Bind attribute of CFSELECT- "Bind failed for select box,bind value is not a 2 D array or valid serialized query." Here is my component: _________________________________ <cfcomponent>     <cffunction name="rptData" access="remote" returntype="string" returnFormat="JSON" output="yes">>       <cfargument name="idVal" type="numeric" required="yes">         <cfquery name="rptName" datasource="advrpt">         select REPORT_NAME from advance.entity t         where t.ID_NUMBER < <cfqueryparam cfsqltype="cf_sql_varchar" value="#idVal#">         </cfquery>         <cfset jsonObj=#SerializeJSON(rptName)#>         <cfreturn jsonObj/>     </cffunction> </cfcomponent> _________________________________

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
brad
03/12/2010 04:39 PM

Is the server call erroring?  Use FireBug or MS Fiddler to capture the actual ajax request and confirm the status code and response body. ~Brad guys, I am getting following error when i access a CFC from Bind attribute of CFSELECT- "Bind failed for select box,bind value is not a 2 D array or valid serialized query."

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
sandeep saini
03/12/2010 04:49 PM

When I use "http://127.0.0.1:8500/prototype/getData.cfc?method=rptData&idval=0000000004" in URL, I get following displayed in browser- "{\"COLUMNS\":[\"REPORT_NAME\"],\"DATA\":[[\"AAA\"],[\"BBB\"]]}" Looks like the JSON object is properly get created. Then not sure whats wrong

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Stephane Vantroyen
03/12/2010 04:52 PM

Hello, you should return it as 'plain', and not as json (it 'double jsonencode' it then) > When I use "http://127.0.0.1:8500/prototype/getData. > cfc?method=rptData&idval=0000000004" in URL, I get following displayed > in browser- > "{\"COLUMNS\":[\"REPORT_NAME\"],\"DATA\":[[\"AAA\"],[\"BBB\"]]}" > > Looks like the JSON object is properly get created. Then not sure > whats wrong

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
brad
03/12/2010 04:56 PM

I think you are double encoding your JSON.  You don't need to put returnFormat="JSON" in the component definition AND use the SerializeJSON() function.  Pick one.  Your CFC is returning JSON- but it is a JSON representation of a string that also just so happens to be a JSON representation of your result set. ~Brad When I use "http://127.0.0.1:8500/prototype/getData.cfc?method=rptData&idval=0000000004" in URL, I get following displayed in browser- "{\"COLUMNS\":[\"REPORT_NAME\"],\"DATA\":[[\"AAA\"],[\"BBB\"]]}" Looks like the JSON object is properly get created. Then not sure whats wrong

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
sandeep saini
03/12/2010 11:33 PM

Big thanks to Brad and Stephane. It did work properly now once I set format as "Plain".


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

July 31, 2010

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
         1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31