|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
JSON object error
guys,sandeep saini 03/12/10 04:30 P Is the server call erroring? Use FireBug or MS Fiddler to capture thebrad 03/12/10 04:39 P When I use "http://127.0.0.1:8500/prototype/getData.cfc?method=rptData&idval=0000000004" in URL, I get following displayed in browser-sandeep saini 03/12/10 04:49 P Hello, you should return it as 'plain', and not as json (it 'double jsonencode' it then)Stephane Vantroyen 03/12/10 04:52 P I think you are double encoding your JSON. You don't need to putbrad 03/12/10 04:56 P Big thanks to Brad and Stephane. It did work properly now once I set format as "Plain".sandeep saini 03/12/10 11:33 P 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> _________________________________ 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." 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 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 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 Big thanks to Brad and Stephane. It did work properly now once I set format as "Plain".
|
July 31, 2010
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||