I am having problems with cfajaxproxy/railo

Posted on 2013-05-24
Last Modified: 2013-08-20
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!
Question by:paddycobbett
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 52

Expert Comment

ID: 39202253
We'd need to see more code. Can you post a small demo example that produces the error?

What version of Railo?

Author Comment

ID: 39204143
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">

LVL 52

Accepted Solution

_agx_ earned 500 total points
ID: 39206579
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' }  });
A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?


Author Closing Comment

ID: 39209509
Worked like a charm! thanks and good insight!
LVL 52

Expert Comment

ID: 39209676
You're welcome (..and I learned something new too !)

Author Comment

ID: 39425909
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 :(

Featured Post

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question