2 Replies Latest reply on Aug 7, 2007 4:02 PM by Stressed_Simon

    Ajax and CFC's

      I am having a 'discussion' and being told that if AJAX calls a cfc method more than once that callingScript1 might get callingScript2's cfreturn info on a heavy AJAX page.
      I run an ajax request to retrieve phone numbers. One call = one phone number.
      Can someone set us striaght
        • 1. Ajax and CFC's
          iKnowKungFoo Level 1
          First of all, it's not a stupid question.

          We have a Batch Payment screen where an Insurance Agent can enter payments for up to 10 policies. As the agent enters a policy number, the system verifies that the agent can access the policy and if so, what is its current status and amounts due.

          A fast typist can tab from row to row entering policy numbers faster than the system can turn around policy information. If we couldn't tie the request and response together correctly, we could potentially display the wrong payment amounts for any number of policies.

          You have two Javascript functions a request and a response. When the Ajax request goes out to the server, an ID is generated with the request. If some data is to be returned to the browser, you also send along the name of the Javascript function that is to be run when the data returns.

          CallingScriptA will not get CallingScriptB's info because neither of them will touch the returned data. They will each have their own return function or will both call the same one. The order in which the data is returned can be an issue. The return data from B may show up before the return data from A. You just have to tell the response function how to handle the data.

          In the case of our batch screen, I send along the row index with each request. I'm only using one Request function and one Response function, but the Response function knows where to display or populate data due to the index value. So its possible for multiple calls to a single method in a CFC to never step on each other.

          Check out Rob Gonda's AjaxCFC project for some examples and more info.


          • 2. Re: Ajax and CFC's
            Stressed_Simon Level 1
            cf_menace has covered off the client side but you can still get an overlap if you have not varred your local variables in your cfc methods.