PDA

View Full Version : [Solved] Ajax: Wait for data loaded



RobSmith
27 Nov 2007, 1:17 AM
I thought it was already a topic here, but I did not find it using the search function. If I missed it, sorry in advance.

I have the following problem:

To create a tabbed panel, the number and the title of these tabs must be retrieved from a server-side script (in this case php). The tabbed panel will be created on demand (when the user navigates to a specified section). So the workflow is the following:

1. User navigates to the section
2. JsonStore.load - to get the data from server
3. wait until data has been loaded
4. created tabbed panel

Step 3 is where i stuck at the moment. Neither setTimeout nor delayedTask seems to be working. Here is the code:

//This function fills the store
var loadResultList = function()
{
objStoreResultList.load({
callback: function(){
blnListLoaded = true;
}
});
}

//And this function is using the store
//(isListLoaded just retrieves the value of blnListLoaded )
getResultListStore: function()
{
if(blnListLoaded == false) loadResultList();
while (blnListLoaded == false){
window.setTimeout('isListLoaded()', 3000);
}

return objStoreResultList;
},

In this case i get an endless loop. Any ideas how to solve it? Thanks in advance.

Phunky
27 Nov 2007, 1:35 AM
Wouldnt it be better to do it like so


1. User navigates to the section
2. JsonStore.load - to get the data from server
3. created tabbed panel
4. Display modal/loading message until data has been loaded

This will then give the user some form of interaction while they wait for the server to respond.

RobSmith
27 Nov 2007, 1:48 AM
The idea is worthwhile to think about, thanks for that, but the problem still seems to remain. It is not (only) the data of the tabs to be created by dynamic data, but also the tabs itself (the title).

RobSmith
27 Nov 2007, 3:21 AM
Have found a (better) way around. Thanks for answering.

Phunky
27 Nov 2007, 3:22 AM
Want to share it with the rest of us?

RobSmith
27 Nov 2007, 3:38 AM
Do not laugh, as it seems so obvious:

The main purpose of the application is to collect as many search queries by the user as desired to display all the search results afterwards in a tabbed panel. My first attempt was to store the search queries information (submitted by form) in a php session variable und retrieve the data via AJAX.

Now I just store the serach query information on the client side as javascript objects and only get the search results via AJAX.


Sometimes it is hard to see the forest as there are so many trees.

Thanks again and uhh, a bit late: ... hello extjs community.