Re: [jQuery] Setting a global variable

2006-12-07 Thread kazaar
Chris Domigan wrote: Synchronous ajax calls freeze the entire *browser* until completed, not just the current script, whereas asynchronous calls do not. Google ajax synchronous for better info on why this is not desirable behaviour. It could be, that I've been using too much Firefox

Re: [jQuery] Setting a global variable

2006-12-06 Thread kazaar
Chris Domigan wrote: Having your scripts broken down into several functions isn't at all an ugly way to do things. IMHO everything should be in a function except for globals. Makes program control a lot easier :) See following 3 different ways to do the same thing. When referring to

Re: [jQuery] Setting a global variable

2006-12-06 Thread kazaar
I'm aware of this, but there can be situations where script can not be allowed to continue, before certain stuff has been done for sure. Klaus Hartl-3 wrote: Synchronous loading isn't the wisest thing to choose. If for instance the request needs a long time due to network problems or

Re: [jQuery] Setting a global variable

2006-12-06 Thread Chris Domigan
Here's a great blog post from Doug Crockford, one of the gods of Javascript on the subject: Many people prefer to use it synchronously. When used this way, the JavaScript engine is blocked until the interaction with the server is complete. Because it blocks, the flow of control looks a lot like

Re: [jQuery] Setting a global variable

2006-12-05 Thread Chris Domigan
Like Blair says, you need to use a callback. I'd do something like this: var seed_id; var seed; function createSeed(callback) { $.post('login/login.php',{action:'createseed'}, function(data) { results = data.split('|'); seed_id = results[0]; seed = results[1]; if (callback)

Re: [jQuery] Setting a global variable

2006-12-05 Thread kazaar
Thank you for quick answers. However, problem still exists. Latter alert-function would still fail, because variables wouldn't be set yet at that moment (I will need those variables later in another call to server). Problem falls back to asyncronous loading. Isn't there an easy way to use

Re: [jQuery] Setting a global variable

2006-12-05 Thread Chris Domigan
Synchronous loading is proposed for jQuery 1.1. But I'm sure callbacks would be able to do what you need... Couldn't you just do: createSeed(restOfScript); function restOfScript() { ... } Then the rest of the script would run after the ajax request has returned. Chris On 06/12/06, kazaar

Re: [jQuery] Setting a global variable

2006-12-05 Thread kazaar
Ok, I'm choosing that path while waiting for jQuery 1.1. Works fine. It's not so critical issue, but the resulting code looks.. well, silly. Chris Domigan wrote: Synchronous loading is proposed for jQuery 1.1. But I'm sure callbacks would be able to do what you need... Couldn't you just

Re: [jQuery] Setting a global variable

2006-12-05 Thread Klaus Hartl
Chris Domigan schrieb: Having your scripts broken down into several functions isn't at all an ugly way to do things. IMHO everything should be in a function except for globals. Makes program control a lot easier :) And in addition to this: Synchronous loading isn't the wisest thing to