You shouldn't be thinking in terms of "storing the JSON data in a variable
for other functions to use."

Instead, you should *call* those other functions from your success callback,
and pass the JSON data as an argument to those functions.

Remember that Ajax calls are asynchronous (the A in Ajax). If you store the
data in a variable, how will those other functions know when it is ready for
use? By calling those functions from the success callback, you insure that
the data is ready and available at the moment of the call.

If you have a more complete example I can probably suggest something more
specific.

-Mike

On Sat, Nov 7, 2009 at 3:19 PM, DigitalDude <e.blumsten...@googlemail.com>wrote:

> Hey,
>
> I need to gather somer data for a jQuery function. I need this data to
> be a json array, which I will achieve in a php action which returns an
> array that is encoded as JSON.
>
> So far, so good.
>
> I need sth like this:
>
>                                        $.ajax({
>                                                        url:
> '/controller/action',
>                                                        data: "ajax=true",
>                                                        dataType: 'json',
>                                                        complete: function()
> {
> },
>                                                        success:
>                                                                });
>                                                        }
>                                        })
>
> but how can I store the data of the returned array into a variable
> which I can then use in other functions of my codeblock?
>
> I think this one is easy but I just started learning it and don't know
> how to do it :(
>
> Thanks,
>
> DD
>

Reply via email to