What causes the JavaScript framework to fail in the live version but works in testing?

I am using ColdFusion 8 on two servers, both with the same version of ColdFusion and with the same settings.

We create a structure in CFC and pass it to the browser using the toScript () function. The resulting JavaScript on the web page looks like this:

TrackingInfo = new Object();
TrackingInfo["child_catalog_id"] = "";
TrackingInfo["ipaddress"] = "";
TrackingInfo["parent_catalog_id"] = 1642;
TrackingInfo["session_id"] = 30000390;
TrackingInfo["referral"] = "";
TrackingInfo["useragent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) G    ecko/20100101 Firefox/10.0.2";
TrackingInfo["querystring"] = "";


Later on the page, in JavaScript, we pass the TrackingInfo (ABOVE) structure to the same CFC - but a different function - using CFAJAXPROXY, like this:

var jro = new JS_SessionTracking();


In CFC, the InsertSessionTrackingFunction takes a structure and injects it into the database,

<cffunction name="InsertSessionTrackingFunction" access="remote">
    <cfargument name="TrackingInfo" required="true">
    <cfset LOCAL.TrackingInfo = ARGUMENTS.TrackingInfo>
    <cfreturn true>


This works flawlessly on our development and milestone sites, tested on many machines and many browsers. It works as engineered and desired.

When we move code into production, every aspect of it works except for the very last function (InsertSessionTrackingFunction). Our server refuses to process JavaScript transmitted by CFC from the web page. There are no bugs in Firebug. The true value is NOT returned.

What can cause the CFC to not like the structure passed to it in the LIVE setup, but does a great job of setting up the development?

Also, I tried to use ColdFusion's serializeJSON () function to format the structure before passing the page to it. It is displayed on the page like this:

LOCAL.TrackingInfo = serializeJSON(LOCAL.TrackingInfo); // serialize the structure

TrackingInfo = "{\"CHILD_CATALOG_ID\":\"\",\"IPADDRESS\":\"\",\"PARENT_CATALOG_ID\":1642,\"SESSION_ID\":30000390,\"REFERRAL\":\"\",\"USERAGENT\":\"Mozilla\\/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko\\/20100101 Firefox\\/10.0.2\",\"QUERYSTRING\":\"\"}";


I passed the structure to a function and used the deserializeJSON function to parse it:

<cfset LOCAL.TrackingInfo = deserializeJSON(LOCAL.TrackingInfo)>


However, this feature works great in development and staging, but doesn't work.

Please give me some ideas as to why this might be happening and how I can fix this problem.


I took Jake Feisel's advice and added <cfset var LOCAL = {}>

to the top of each function to ensure that the values ​​don't float around. While this seems like a good habit in CF8, it didn't fix the problem.

The code below works very well in production and in our live environment. No changes to CFCs were required to do this job. ColdFusion simply won't allow this structure to be passed to a function on this server.

        #toscript(TrackingInfo.SID, "SID")# 
        #toscript(TrackingInfo.parent_catalog_id, "Parent")#
        #toscript(TrackingInfo.child_catalog_id, "Child")#

  var jro = new JS_SessionTracking();



source to share

2 answers

Common troubleshooting places for finding differences between tests and prod:

  • different data (maybe a wildcard causing an error?)
  • differences in web server infrastructure (reverse proxy causing cache issues; various modules included;)
  • browser settings (cached pages are disabled in testing and dev, but not prod)
  • Additional complexity of server configuration (for example, subdomains or different ports) for hosting the main page and Ajax requests; this will result in the same problem origin policy .

However, we have now eliminated them as possible sources of problems in your particular case ....

You say that all your CF versions are the same and that you are using CF 8. However, the local scope you are trying to use was introduced in CF 9:


Since (from your comment) you are seeing an error here, I suspect this is the problem.


One thing worth mentioning regarding the use of LOCAL in CF8 is that using this will not result in an error, but it may result in unexpected behavior (perhaps as you see here).

<cffunction name="foo">
    <cfset local.bar = "Hello World">

    <cfreturn local.bar>


I've tested the above example in CF8 and it "works" - it doesn't throw an error. However, what it will do is create a new structure named "local" in the variable scope for the request or component (depending on where the function is located). It will then be globally available in that context (and potentially persistent if you cache the CFC instance). If this is a shared, cached CFC instance, it is likely that if you push this to multiple clients at the same time (especially noticeable if the function is running for a long time), you will be overwriting this local variable with each request.It is just a problem that will not be obvious in development or creation, since the number of users immediately gets to the site. Also, if you use the same name in different functions, each one could potentially conflict with your executable instance, forcing someone to know what the problem is.

Your best bet would be to update your function by adding one line:

<cffunction name="InsertSessionTrackingFunction" access="remote">
    <cfargument name="TrackingInfo" required="true">
    <cfset var LOCAL = {}>
    <cfset LOCAL.TrackingInfo = ARGUMENTS.TrackingInfo>
    <cfreturn true>


This will explicitly limit your local scope to your function.

You may not be seeing the error in firebug because perhaps you have some sort of global error handler that suppresses CF errors, perhaps only disabled during production.



The CF Administrator has a Serialized JSON Prefix with option and the default is //

. If this setup is different from your test and production systems, it can cause problems.



All Articles