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

Search cf-talk

July 04, 2009

<<   <   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   

Home /  Groups /  ColdFusion Talk (CF-Talk)

having trouble with CFJSON / Spry

  << 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:
Jonathon Stierman
07/04/2007 09:30 PM

I've got a webservice running that converts some various CF objects into JSON - Seems to be working alright, but I'm running into a vexing issue. When I call the service via Spry, I get an error from SpryDebug.js: "Caught exception in JSONDataSet.loadDataIntoDataSet: SyntaxError: missing } in XML expression" What's confusing is that if I call the service myself, copy the contents into a .js file, and then have Spry call straight from that .js file, it works just fine!  Here's the JSON my Service returns, if that helps: {     "recordcount":3,     "columnlist":"categoryid,matchid,name",     "data":     {       "categoryid":[3,3,3],       "matchid":[1,2,3],       "name":["some dude","random guy","joe schmoe"]     } } My service code (condensed) is pretty basic.  I pass in a Query object (results) and tell CFJSON to format it as a query: <!--- transform the result into JSON ---> <cfset results = Variables.jsonCFC.encode(     data = results,     queryFormat = "query"   ) /> <cfreturn results /> I am running on a development server, so I get that meta data on every CF request: <META NAME="ColdFusionMXEdition" CONTENT="ColdFusion DevNet Edition - Not for Production Use."> Could that be the culprit?  If so, how do you guys develop AJAX apps without running into this issue? Jonathon

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
07/04/2007 10:19 PM

Could be two things here. First - yes - that meta tag could most likely be breaking stuff. I don't know as I run a non-dev edition locally. Secondly - and this is what concerns me the most - do not forget CFCs return data in XML. Either WDDX form or plain XML. So even though you returned JSON, it was turned into XML. Not translated, wrapped I should say. You would need to point Spry to a CFM page instead. FYI, CF8 fixes this by letting you specify a return format for CFC methods. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dan G. Switzer, II
07/04/2007 10:31 PM

Yes, the Dev Net tag breaks things. The easiest solution is to just stop using the Dev Net edition and go to the Developer Edition. The Dev Net Edition has unlimited IPs, but places the meta tag in each request automatically. The Developer Edition is limited to a single visiting IP address. They both are essentially the same as the Enterprise version with their own restrictions. -Dan ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
07/04/2007 10:42 PM

So two people say its the META tag, and I'm sure that's right, but no one else also thinks he has an issue with the WDDX-ifying as well? ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Andrew Scott
07/04/2007 10:55 PM

Ray, I use CFC's all the time with Json, the trick is not to use the cfreturn tag under cfmx7 and below but to output it instead. Have a look at how I do it with http://CFJsonService.riaforge.org and you see what I mean. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613  8676 4223 Mobile: 0404 998 273 So two people say its the META tag, and I'm sure that's right, but no one else also thinks he has an issue with the WDDX-ifying as well? ----- Excess quoted text cut - see Original Post for more ----- own ----- Excess quoted text cut - see Original Post for more ----- methods. > > > > > >> I've got a webservice running that converts some various CF objects into > >> JSON - Seems to be working alright, but I'm running into a vexing issue. ----- Excess quoted text cut - see Original Post for more ----- contents > >> into a .js file, and then have Spry call straight from that .js file, it ----- Excess quoted text cut - see Original Post for more ----- CF ----- Excess quoted text cut - see Original Post for more ----- Not ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jonathon Stierman
07/05/2007 11:54 AM

So that would get rid of the "WDDX-ifying" -- but I'm still left with fighting that META tag CF puts in there.   I work from a network, and there are definitely other people using the CF server, so I'm not sure how I'll be able to get around the single IP issue, but I can definitely look into the Spry code and try to find a place to strip out the META tag.  Let's see if I can make this work! Thanks Andrew, Ray, and Dan!   Jonathon   Ray, I use CFC's all the time with Json, the trick is not to use the cfreturn tag under cfmx7 and below but to output it instead. Have a look at how I do it with http://CFJsonService.riaforge.org and you see what I mean. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613  8676 4223 Mobile: 0404 998 273 So two people say its the META tag, and I'm sure that's right, but no one else also thinks he has an issue with the WDDX-ifying as well? ----- Excess quoted text cut - see Original Post for more ----- own ----- Excess quoted text cut - see Original Post for more ----- methods. > > > > > >> I've got a webservice running that converts some various CF objects into > >> JSON - Seems to be working alright, but I'm running into a vexing issue. ----- Excess quoted text cut - see Original Post for more ----- contents > >> into a .js file, and then have Spry call straight from that .js file, it ----- Excess quoted text cut - see Original Post for more ----- CF ----- Excess quoted text cut - see Original Post for more ----- Not ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dan G. Switzer, II
07/05/2007 12:16 PM

Jonathon, >So that would get rid of the "WDDX-ifying" -- but I'm still left with >fighting that META tag CF puts in there. > >I work from a network, and there are definitely other people using the CF >server, so I'm not sure how I'll be able to get around the single IP issue, >but I can definitely look into the Spry code and try to find a place to >strip out the META tag.  Let's see if I can make this work! Here's a good blog entry which gets to the heart of your problem: http://www.talkingtree.com/blog/index.cfm/2005/6/15/DevNet2Developer There are a few comments that are bit "looney", but I think you can find enough information on that page to resolve your issues. -Dan

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
07/05/2007 10:46 PM

Wow, well, I wouldnt normally recommend outputting directly like that - but if it solves your problem, more the better. Boy am I glad returnFormat was added to CF8. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Andrew Scott
07/04/2007 10:29 PM

Yes the issue is the meta tag. Having done a lot of Dojo work and also creating http://CFJsonService.riaforge.org I found that you can't evaluate a json object if there is something there that is not json expected. Your only bet is to modify the call, where it does the http request within spry, and do something like this. var strTest = http.responseText; strTest = strTest.replace(/(<\/?META[^>]*>)/gi,''); Which removes the meta tag. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613  8676 4223 Mobile: 0404 998 273 I've got a webservice running that converts some various CF objects into JSON - Seems to be working alright, but I'm running into a vexing issue. When I call the service via Spry, I get an error from SpryDebug.js: "Caught exception in JSONDataSet.loadDataIntoDataSet: SyntaxError: missing } in XML expression" What's confusing is that if I call the service myself, copy the contents into a .js file, and then have Spry call straight from that .js file, it works just fine!  Here's the JSON my Service returns, if that helps: {     "recordcount":3,     "columnlist":"categoryid,matchid,name",     "data":     {       "categoryid":[3,3,3],       "matchid":[1,2,3],       "name":["some dude","random guy","joe schmoe"]     } } My service code (condensed) is pretty basic.  I pass in a Query object (results) and tell CFJSON to format it as a query: <!--- transform the result into JSON ---> <cfset results = Variables.jsonCFC.encode(     data = results,     queryFormat = "query"   ) /> <cfreturn results /> I am running on a development server, so I get that meta data on every CF request: <META NAME="ColdFusionMXEdition" CONTENT="ColdFusion DevNet Edition - Not for Production Use."> Could that be the culprit?  If so, how do you guys develop AJAX apps without running into this issue? Jonathon


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

Mailing Lists