[jQuery] Re: Problem with Ajax callback function in jQuery

2009-08-20 Thread dkomo872
On Aug 20, 11:53 am, ak732 wrote: > Just be aware that doing the ajax call synchronously will block (lock > up) the browser until the request/response completes.  This is > typically okay when running locally, but can be very noticeable when > running on slower connections (e.g. shared hosting)

[jQuery] Re: Problem with Ajax callback function in jQuery

2009-08-20 Thread ak732
Just be aware that doing the ajax call synchronously will block (lock up) the browser until the request/response completes. This is typically okay when running locally, but can be very noticeable when running on slower connections (e.g. shared hosting). There's no reason why you cannot do this a

[jQuery] Re: Problem with Ajax callback function in jQuery

2009-08-20 Thread dkomo872
On Aug 20, 6:59 am, MorningZ wrote: > "Does anyone know what is wrong?  I've never seen an ordinary function > behave this way. " > > That's because $.post (and the resultant $.ajax) isn't "ordinary", > it's an asynchronous call and when you hit the line > >  jsonData = eval('(' + data + ')');

[jQuery] Re: Problem with Ajax callback function in jQuery

2009-08-20 Thread MorningZ
the code i posted should have no problem working as long as it is used properly... without seeing your actual HTML and where stuff is and what gets called, it's impossible to help completely. and the / thing won't matter that much as long as document.ready is used... but even that's a guess

[jQuery] Re: Problem with Ajax callback function in jQuery

2009-08-20 Thread MorningZ
and just to note success = SaveSearch_Success, should look just like that... it shouldn't be success = SaveSearch_Success(), or success = SaveSearch_Success(data), or *anything else*... it already "knows" to pass the resultant JSON to the function On Aug 20, 9:34 am, dkomo872

[jQuery] Re: Problem with Ajax callback function in jQuery

2009-08-20 Thread dkomo872
On Aug 20, 6:26 am, Chrazy wrote: > From the looks of it, why don't you use the $.ajax function and do > your stuff on success? Seems like an easier way to structure things. > > Sometimes a variable used in a function that you want to use elsewhere > has to be stored somewhere as it won't be re

[jQuery] Re: Problem with Ajax callback function in jQuery

2009-08-20 Thread dkomo872
On Aug 20, 6:59 am, MorningZ wrote: > "Does anyone know what is wrong?  I've never seen an ordinary function > behave this way. " > > That's because $.post (and the resultant $.ajax) isn't "ordinary", > it's an asynchronous call and when you hit the line > >  jsonData = eval('(' + data + ')');

[jQuery] Re: Problem with Ajax callback function in jQuery

2009-08-20 Thread ak732
Try doing this and see if it works: #msg_div {font-color:red;} $.post('save_search.php', formData, function(data) { jsonData = eval('(' + data + ')'); if (jsonData.return_status.search("successful") > -1) { $('#msg_div').html("Search was saved"); } else { $('#msg_div').html("Search

[jQuery] Re: Problem with Ajax callback function in jQuery

2009-08-20 Thread dkomo872
On Aug 20, 7:01 am, Leonard Martin wrote: > The trouble is that the $.post is run asynchronously so anything after > the $.post will be executed before the callback function. > > If you want the returned data to be available outside the callback > then it will have to be inside a function which

[jQuery] Re: Problem with Ajax callback function in jQuery

2009-08-20 Thread MorningZ
"Does anyone know what is wrong? I've never seen an ordinary function behave this way. " That's because $.post (and the resultant $.ajax) isn't "ordinary", it's an asynchronous call and when you hit the line jsonData = eval('(' + data + ')'); the script isn't back from the post call yet

[jQuery] Re: Problem with Ajax callback function in jQuery

2009-08-20 Thread Leonard Martin
The trouble is that the $.post is run asynchronously so anything after the $.post will be executed before the callback function. If you want the returned data to be available outside the callback then it will have to be inside a function which is called from within your callback method. e.g. v

[jQuery] Re: Problem with Ajax callback function in jQuery

2009-08-20 Thread Chrazy
>From the looks of it, why don't you use the $.ajax function and do your stuff on success? Seems like an easier way to structure things. Sometimes a variable used in a function that you want to use elsewhere has to be stored somewhere as it won't be recognized globally. Check http://docs.jquery.c