I love the idea of creating the non-page-refreshing apps,
but, as someone mentioned earlier, even a relatively simple
app just start to overflow with code and it becomes difficult
to keep up with what is doing what and when.

Someone mentioned earlier, that instead of putting all their
js code on the page, they used includes to include only what
they needed at a particular time.

How are these includes done with js?  Is it similar to
<cfinclude> with CF?

Can you give me a simple example?  (I just need to done some
research on js includes...)

I really need some way to encapsulate my code to make it
more manageable.

I mentioned remembering in an earlier posts writing BASIC
subroutines back in 1980 that worked very well.  I say it
worked very well, but it was probably more work than what
I have now.  But it was easy to say GOTO 1540 to launch
the subroutine that started at line 1540.  Boy, things have
gotten complicated today!  (But there were not even graphics
of any significance back then!  It was CompuServe at $6.00
per hour for text-based communications!)

Rick

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Michael Geary
Sent: Thursday, April 09, 2009 10:19 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Get var out of ajax scope


That's perfect, Rick, it's exactly the way I would have coded it.

Hang in there on this client-side stuff! It will all continue to become more
clear as you work with it.

I have some sympathy for what you're going through with it. As more of a
front-end guy, it happens to me every time I tackle back-end stuff like
databases. Help me! Databases! Why can't it be something simple like
closures and asynchronous Ajax calls? ;-)

-Mike

> From: Rick Faircloth
> 
> 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 Michael Geary
> Sent: Thursday, April 09, 2009 8:20 PM
> To: jquery-en@googlegroups.com
> Subject: [jQuery] Re: Get var out of ajax scope
> 
> 
> There's something missing in each of these solutions.
> 
> What about the code that will use this variable: How does 
> that code know
> when the variable is ready to use?
> 
> That code could check to see if the variable is null, but 
> what does it do
> then? Try again later? How much later?
> 
> What's more likely to be needed is that the complete() 
> function *calls* that
> other code as a function. Then you know the data is 
> available, and you can
> pass the data value directly to that function as an argument.
> 
> You can still put the data in a global variable, but there 
> may not be any
> need to do that since you have to make a function call anyway.
> 
> -Mike
> 
> > -----Original Message-----
> > From: jquery-en@googlegroups.com 
> > [mailto:jquery...@googlegroups.com] On Behalf Of Eric Garside
> > Sent: Thursday, April 09, 2009 4:34 PM
> > To: jQuery (English)
> > Subject: [jQuery] Re: Get var out of ajax scope
> > 
> > 
> > Well, you've got two basic options. You can do a 
> > straightforward global variable like Hector suggested, or you 
> > can create and use a custom storage object in the jQuery 
> > namespace. Try adding to your
> > code:
> > 
> > $.__customStorage = {};
> > 
> > $.get({
> >   url: 'some.page.php',
> >   complete: function(data){
> >      $.__customStorage.ajaxResponse = data;
> >   }
> > });
> > 
> > On Apr 9, 6:47 pm, Hector Virgen <djvir...@gmail.com> wrote:
> > > Something like this might work:
> > > var ajaxResponse;
> > >
> > > $.ajax({
> > >     url: 'ajax.php',
> > >     complete: function(response) {
> > >         ajaxResponse = response;
> > >     }
> > >
> > > });
> > >
> > > -Hector
> > >
> > > On Thu, Apr 9, 2009 at 3:44 PM, Nic Hubbard 
> > <nnhubb...@gmail.com> wrote:
> > >
> > > > I have an $.ajax() call that I am using to GET some text 
> > from a page 
> > > > on my site.  I have put it in a variable with the success 
> > function.
> > > > How can I move that var up and out of the $.ajax function 
> > so I can 
> > > > use it in other parts of my script?
> > >
> > > > Thanks.
> > 
> 
> 


Reply via email to