View Full Version : Store load method

7 Apr 2010, 2:43 AM
Hi all,
I have a store that load it's data from server. I want to get responseText of server when run load method of store? Is there any way for this?

In callback function of store.load() we can get loaded records only.

7 Apr 2010, 5:56 AM
If i get the idea you can just enter the stores url directly into the browser, can't you?

Mike Robinson
7 Apr 2010, 9:01 AM
Remember this ...

AJAX is like "sending postcards through the mail."

When you call the load() method, your computer "fills out a postcard asking for the information to be sent, and drops the postcard into the mailbox." That's all that happens now.

Sometime in the future, a reply's going to come back. Could be in 1/10th of a second; could be 2 minutes from now. You don't know. You don't (have to...) care.

That is to say ... at some point in the future, one of three things will happen:

The HTTP connection will drop dead.
A reply will come back from the host, with "success: false."
A reply will come back from the host, with "success: true."

If the response is "success," then there will also be data. The Store object will file-away the data that the host sent, and then it will fire the "load" event so that you can respond appropriately.

But... nothing can happen at the point when "you drop the postcard into the mailbox." Your response will depend on what's on the postcard that the host sends back, and that hasn't happened yet.

Everything in the JavaScript world occurs through this fundamental mechanism of events. ("When the postcard arrives, and if it indicates success, then we will trigger the event. Don't call us... we'll call you.")

AJAX = Asynchronous JavaScript.

7 Apr 2010, 11:40 PM
Ok Mike, thanks for your mention.
Let me i ask my question like this: Do store load method and Ext.Ajax.request have different mechanism? When we use Ext.Ajax.request, we can access to server responseText easily but how we can access it when run load method of store?

When we run load method, where does server response process?

In my host response there are a success field and a message field that message field will contained error message when success=false. I want access to these field but when call load method no Ext.Ajax.request.

8 Apr 2010, 2:27 AM
Just from reading the docs (no experience):
Have you tried to listen to the "exception" event from the Store. Looks like DataProxy can offer the decoded response with your message attribute.

8 Apr 2010, 2:29 AM
You can access the data block used to create Records from the last load through the Reader. Check API docs for your configured Reader type.

And bear in mind what Mike told you about the asynchronous nature of Ajax requests.

8 Apr 2010, 2:54 AM
Exception event is fired when i receive success field false from server but i don't see any thing about server response.

Do we must use Ext.Ajax.request() only, when we want to process server response?

8 Apr 2010, 3:03 AM
Ok, very thanks animal
I think i found it. I just was looking in Api docs of Store and DataProxy.