blog | bio | agenda | jobs | ajaxCFC

ajaxCFC documentation added

I just updated the ajaxCFC download with initial documentation. I’ll keep improving as there is always room for improvement, but it has the minimal explanations and instructions to install and use.

If I’m missing something please do not hesitate to contact me, I will appreciate it.

TrackBacks
There are no trackbacks for this entry.

Trackback URL for this entry:
http://www.robgonda.com/blog/trackback.cfm?1D7223FF-3048-7431-E4F80B32A9DA6944

Comments
rob,

i ran ajaxCFC (The one link you posted on my blog), tried the ECHO test, and got an invalid response from server error, right away.

any ideas?

thanks.
tony
# Posted By tony of the weeg clan | 12/12/05 9:42 AM
Tony,

Can you please more details? Did you run it from my server, or did you download it and ran it elsewhere? I just tested http://www.robgonda.com/blog/projects/ajaxcfc/exam... in 5 different browsers and they all worked.

Please provide details so I can either help debugging it or fix it to extend cross-browser support.

Thanks

-Rob
# Posted By Rob Gonda | 12/12/05 9:47 AM
Same problem here. I downloaded the zip file and copied the 'examples' folder to the 'test' subdir on my site.

Tried http://localhost/test/examples/complexObjects/inde... and clicked the 'send' button. Received 'invalid response from server' message.

Tried in FF 1.0.7, FF 1.5, and IE 6.
# Posted By Steve | 12/12/05 5:15 PM
After some debugging, something jumped out at me. Going through the routines I see some null values (usually never good).

batch.path = "echoTest.cfc"
statsInfo = "null.echo"
query=""method=init&callCount=1&c0-scriptName=null&c0-methodName=echo&c0-id=9922_1134429393155&c0-param0..."
# Posted By Steve | 12/12/05 5:19 PM
I think I see part of the problem. Looks like a mismatch is happening somewhere.

In my current run, the batch.map structure's callCount property is 1, yet the other sciptName property is labeled "c0-scriptName" and its value is "null". Brief looks at the code, it should be trying to reference "c1-scriptName".
# Posted By Steve | 12/12/05 5:30 PM
Steve,

Thank you for all the provided information. I will try to download the zip that's up there and get back to you shortly.

-Rob
# Posted By Rob Gonda | 12/12/05 5:56 PM
Steve, btw, the ScriptName = null is correct, and so is the c0 prefix. The call count is 1, but the prefixes are 0 based.

I just copied the complexObjects to 2 sites I have, one running cfmx6.1 and the other cfmx7.0.1... both of them ran fine.
I had them under:
http://www.somesite.com/test/complexObjects
and the JS folder at http://www.somesite.com/test/JS

I'm pretty sure you had the JS folder installed correctly, otherwise you would have seen the batch in the URL.

Do me a favor, try to debug it again (I use FF and live http headers), and check the server response. Actually, I’m not asking to you hack my own site :) but try debugging my example. You can actually right click the URL I’m calling (the one with the c0's) and paste it into a new browser and you’ll see the JavaScript response. You can do this because where’re using get verbs… You can change it to force post verbs, but that’s a different story; anyways, I’m digressing, if you do that in my site you’ll see a response, starting with something similar to ‘_9370_1134433016390 = new Object();’

Please try that in your server too and let me know what it says…

Thank you for your support.
# Posted By Rob Gonda | 12/12/05 6:24 PM
Thanks to Tony I found what was bugging out on some web servers. I was calling the cfc’s with the following format: /path/file.cfc/exec/methodname?somevars

It worked fine with Apache and IIS6, but seems like some Web Servers, or Firewalls perhaps were blocking this syntax… I am still unsure which one was the exact cause, but Tony pointed me to his files and I was able to make it work by rewriting the url in a different format.

I just updated the zip file; make sure you clear your cache, especially Firefox users, as it caches all Javascripts and won’t pick up the changes unless you do so.

Cheers

-Rob
# Posted By Rob Gonda | 12/12/05 9:22 PM
different error now :) (dont you just love bugs!)

[Object Error]

and same external path btw to hit it rob.
# Posted By tony of the weeg clan | 12/12/05 10:03 PM
Tony,

Did you clear your cache? I just tested your link and it came back fine... both btw, the echo and the complexObjects... please make sure you clear your cache and try again.

-Rob
# Posted By Rob Gonda | 12/12/05 10:12 PM
and you did say to do that :) although im not really hitting it... im just using homesite+ and browsing... which kinda sucks... let me try with a browser actual.
# Posted By tony of the weeg clan | 12/12/05 10:51 PM
Interesting, I'll make a special note about hitting it with Homesite.
Thanks,
Rob
# Posted By Rob Gonda | 12/12/05 11:06 PM
LOL, I got the same [Object Error] response when I tried your new code. After a few minutes, I decided to see what the response was so I could see where the problem might be.

Problem turned out to be ColdFusion Debugging information. Soon as I turned off debugger, everything starts working kosher. Anyone else reading this, make a mental note! :)
# Posted By Steve | 12/13/05 9:18 AM
Steve,

That makes sense now … Tony said that his code worked remotely, from the office, and from my pc too, but he couldn’t run it locally; probably again because of the same thing… debugging turned on for localhost.

I’ll add some adjustments to turn off debugging automatically for the ajax calls.

-Rob
# Posted By Rob Gonda | 12/13/05 9:58 AM
How can I get the length of r in the result function? I've tried r.length. I am returning a query and I want to loop through the records.
Thanks
Tony
# Posted By Tony G | 12/20/05 4:49 PM
Tony,

I'm heading out, so I'll add this to the documentation later;

anyways, you can do the following when receiving recordsets in the call back function:

alert( r.getRowCount() ); // will get your the recordcount

and

document.write( r.dump() ); // dump() will return a full data dump.

it comes as a structure of arrays, not an array of structures... that's why you can't get r.length.

you need to use r.col[i] instead of r[i].col

hope it helps.
# Posted By Rob Gonda | 12/20/05 11:05 PM
I was also having the [object error] problem, and in my case it turned out to be because of the onrequestend.cfm in which I was outputting some of own custom debugging info. Dunno if you can do anything to cater for that.
# Posted By Russ Michaels | 3/9/06 5:48 PM
Russ,

Yes you can. There's a setter that's part of ajax.cfc that aborts the request after processing the response. Simple call the setAbortAfterRequest(true) function in your components (the one that extends ajax). Add that line outside all functions, so it gets executed onLoad.
# Posted By Rob Gonda | 3/9/06 7:47 PM
I created a mock up vin number lookup for the company I am work for. When I added it into my companies site to demo it, if failed. Using IE, I got a [object Error] and all I did was just dump the code onto an exsisting page. The only change I made was that I created a seperate directory that contained the js folder and the ajax.cfc file along with my cfc extended file.

Doing some simple debugging, I know that the cffunction is being called but on return I get an object error. I don't see how this could happen since no code has changed except for location of the files being used for ajax.

Any idea?
# Posted By niel | 8/7/06 2:30 PM
Hello, sorry about the english i'm an spanish guy... I have been recently working with ajaxcfc, because i just want to make a simple remote access to a database without refreshing the browser... i just can't make it... i will paste here my code hoping somebody help me... thanks...


this is what i have written in the client side:

<script type='text/javascript'>_ajaxConfig = {'_cfscriptLocation':'Components/my_com.cfc', '_jsscriptFolder':'ajaxCFC/core/js'};</script>

<script type='text/javascript' src='./ajaxCFC/core/js/ajax.js'></script>



<script type="text/javascript">
function imprimir_modelos(result)
{
    alert(result);
document.getElementById('td_modelos').innerHTML=result;
}

function modelos_de(id)
{
alert(id);
DWREngine._execute(_ajaxConfig._cfscriptLocation,null,'f_modelos',imprimir_modelos);
}
</script>


and here is my component on the server side:

<cfcomponent extends="ajax" >
   
   <cffunction name="f_modelos" access="public" returntype="string">
      
      
      <cfargument name="id_categoria" type="numeric" required="no">
   
      <cfset myResult="">
      
      <cfif IsDefined("arguments.id_categoria") AND arguments.id_categoria NEQ "">
         
         <cfquery name="q_modelos" datasource="#request.dsn#" username="#request.dsnUsername#" password="#request.dsnPassword#">
            select * from tbl_products where product_Category_ID = #arguments.id_categoria#
         </cfquery>
         
         <cfoutput query="q_modelos">
         
            <cfset myResult = myResult & '<input name="model_#product_ID#" type="button" value="#product_Name#">'>
         
         </cfoutput>
         
      </cfif>
      
      
      
      <cfreturn myResult >
   
   
   </cffunction>


</cfcomponent>

sometimes it show me an error like an "alert" saying "object error", and sometimes "invalid reply from server"

thanks
# Posted By kmi | 5/2/07 9:47 AM
Try to use an http traffic sniffer such as Fillder, Firebug, or Service Capture to see the server's response. Once you see what you get back from the server, it should be pretty simple to correct it.

HTH
# Posted By Rob Gonda | 5/2/07 2:33 PM
hi, we've been using ajaxCFC which seems to work fine on our Production Server, and our Test Server, but does not seem to work in our local environments on our laptops. One uses ColdFusions web server, the other uses IIS, but neither work. We get the [Object Error] message. I've tried tracing and debugging in Firefox/Firebug (very useful, by the way). I'm able to set breakpoints, step through it line by line, see values for all variables, etc. In the engine.js DWREngine._sendData function, I get to the following line:
batch.req.open("POST", batch.path, batch.async);

The same files and same exact code work on 2 different servers, with all kinds of ajax usage scenarios (querying data, saving data, auto-suggest controls, etc.) -- but none of them work on our laptops -- indicating some sort of configuration issue.

We did see some of the other posts here, and have since turned off Debugging, clearing the cache, but nothing seems to help. We just keep getting the [Object Error] message.

Anything anyone can recommend? or any other testing paths to go down?
Any help would be greatly appreciated.

Scott
# Posted By Scott | 6/22/07 6:52 PM
As a follow up to the post above, the batch.req seems to be an XMLHttpRequest. Is there a problem with executing an XMLHttpRequest locally (?).
# Posted By Scott | 6/24/07 2:53 PM
@Scott, I highly recommend you install some sort of http traffic analyzer, such as Firebug, Fiddler, Service Capture, or Charles. They will show you the exact request/response message and indicate that the server's responding. If it's only locally, it might be related to CF Debugging.

HTH
# Posted By Rob Gonda | 7/10/07 1:22 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.1.004.