I am having problems with cfajaxproxy/railo

I am having problems with using cfajaxproxy with railo, where by calling some of my remote functions will result in a JSONParse error being thrown in the browser. I have managed to identify which functions execute successfully and which fail and it appears to be due to the types of the parameters. Simple types such as strings and booleans work fine, i.e:

<CFFUNCTION name="activate" access="remote" output="no">
      <CFARGUMENT name="webpageId" type="string" required="yes">
      <CFARGUMENT name="isActive" type="boolean" required="yes">

However, any function which requests a struct or array as a parameter, i.e:

<CFFUNCTION name="activate" access="remote" output="no">
      <CFARGUMENT name="webpageId" type="struct" required="yes">

will result in the JSONParse error described. The same function works perfectly using CF9, but when run in the railo environment it throws that error. Does any one have any ideas as to what might be causing this? .. or suggest anything to try?

Many thanks!
Who is Participating?
_agx_Connect With a Mentor Commented:
Interesting.  The FF debugger shows it's using the structure param as the "argumentCollection".  So what's actually passed to the function is a parameter named "struct" with a value of "structval" .  


For it to work, I think you need to do something like this instead:

       proxy.testWithStruct( {structParam:   { struct: 'structval' }  });
We'd need to see more code. Can you post a small demo example that produces the error?

What version of Railo?
paddycobbettAuthor Commented:
Sure, the following code runs successfully in a CF environment, yet fails in the Railo environment.  Do you have any idea why this could be?  Is is related to an environment setup issue? Could you try this is your railo environment (assuming you have one set up) and see if it works? That would eliminate it being a code issue. Am running railo

<cfajaxproxy cfc="testcfc" jsclassname="testcfc" />

 var proxy=new testcfc();
  alert('string test succeeded!');
 proxy.testWithString('teststring'); // succeeds
 proxy=new testcfc();
  alert('struct test succeeded!');
 proxy.testWithStruct({ struct: 'structval' }); // fails


### test.cfc


 <CFFUNCTION name="testWithString" access="remote" returnFormat="json" output="no">
  <CFARGUMENT name="stringParam" type="string" required="yes">
 <CFFUNCTION name="testWithStruct" access="remote" returnFormat="json" output="no">
  <CFARGUMENT name="structParam" type="struct" required="yes">

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

paddycobbettAuthor Commented:
Worked like a charm! thanks and good insight!
You're welcome (..and I learned something new too !)
paddycobbettAuthor Commented:
Hi, I know this is an old question but had a quick follow up which is not easily posed as a separate question. Since railo handles the ajax parameters differently, is there an obvious way in which I can call the ajax function that is compatible for both railo and non-railo? Just wanted to check before I adjust my calls for railo which will break if it's not run in the railo environment. I wish I could award follow up points :(
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.