Hi, JB...

I never did get back to your question about transferring variables
between functions, but took up this question in another thread.
Here's what I posted in answer to another poster's question:

Also, since I've having the same problem with too much jQuery/AJAX/HTML
going into a single page, I'd like to know more about how you're
structuring your code with the includes and pulling your needed
code into a DIV.

Can you give an example that demonstrates this "framework" that you use?

Thanks,

Rick

Here's the response to transferring variables...

---------------------------------------------------------

Here's a method that I'm using to pass data from
an ajax response to another function:  (I'm starting
with the success: section of an ajax call)

success:   function(response) {
              if    ( response.MESSAGE == 'Success' )
                    { populateStoryTable(response); }

              else  { alert(Rats!  No good!);       }

That makes all of the data sent back in "response"
available to reference in the function "populateStoryTable".

It's transferred to the populateStoryTable function by using

populateStoryTable(response) {

   ...whatever code I want to run...

That's just a way to directly link the functions with the
data they need.

Michael, this is the method you're referring to which calls
the next function that's needed when the data is ready.

I've used this method of putting variables inside the () after
a function call to pass data all around.

If I do an inline function call, I can use "myFunction(story_id)"
to pass a story_id to the "myFunction" function.

I'm just learning about this stuff, really, so I'm sharing how
I'm managing to make some of the jQuery and especially ajax stuff
work.

I've been working for a month trying to get an ajax app finished
that I could have completed in a day with standard "page-to-page"
processing, passing variables through url's and session, but I'm 
bound and determined to make this work.  I keep writing and re-writing
the app as I learn more.

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of JBeckton
Sent: Thursday, April 09, 2009 7:31 PM
To: jQuery (English)
Subject: [jQuery] Re: Managing scripts in AJAX applications


Hey...

I am using ColdFusion as well on the FuseBox Framework.

I have somewhat of a slick way to handle the js resources, it was
great at first but the more screen/interfaces I have the more
difficult it becomes to manage the js. I basically have a .cfm page
with html and dynamic data with none of the HTML Doc tags, that I pull
in via AJAX and inject into a div. I use get jQuery.getScript( url,
callback ) to pull the supporting script in for the HTML I got from
the server.

I'de be interested in learning how your transferring variables between
functions.

Thanks


On Apr 2, 5:39 am, "Rick Faircloth" <r...@whitestonemedia.com> wrote:
> Hi, JMan...
>
> Did you get any answers to your questions?
>
> I've been working a lot with jQuery/ajax/ColdFusion
> lately.  It's all new to me and I've been learning a lot.
> Perhaps some of what I've learned may be of use to you.
>
> I haven't been injecting HTML into the DOM of the ajax
> calling page, but creating HTML to display ajax results.
>
> And I've also learned some about being able to transfer
> variables between functions.
>
> Does any of this sound like what you're looking for?
>
> Let me know.  I'll be glad to share some code samples
> with you.
>
> What's you backend language?
>
> Rick
>
> -----Original Message-----
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
>
> Behalf Of JMan
> Sent: Wednesday, April 01, 2009 1:40 PM
> To: jQuery (English)
> Subject: [jQuery] Managing scripts in AJAX applications
>
> One thing I have been struggling with is AJAX applications is managing
> the js code that powers them.
>
> For example if you have a page that loads content from an AJAX call to
> the server and that content also has js code associated with it in
> order to function how do I manage that code? If I have 20 pages that
> get loaded from the server via AJAX at one point or another I do not
> want to have one huge js file with a bunch of code for each page in
> it.
>
> I was wondering if it's better to embed the js for each page loaded
> via AJAX or call it separately? Normally when I need chunks of HTML &
> js, like a data grid for example; that get loaded in via AJAX call I
> do not have this called code in the traditional HTML doc, in other
> words the HTML being loaded has no HTML head, body etc.. it's just
> HTML generated by the server and injected into a section of the
> calling page. So in this situation should I load the script that is
> required by the HTML via the success callback?
>
> Another delima is communicating events and such between chunks of
> loaded HTML/js, like if I have a Tabs widget and an accordion on the
> same page and each have content loaded via AJAX and the content in tab
> 1 needs to bind and interact with events in a section of the accordion
> content loaded via AJAX.

Reply via email to