PDA

View Full Version : Store returning the previous requests result



bevara.siva
24 Jul 2014, 2:23 AM
Hi,
We are using ExtJs 4.2.2

We are trying to implement Login functionality.
We are authenticating the user in the WCF service and returning the result as JSON.

We have created a JSON store in the client to post the request and get the response.
Initially in the store I gave the URL and dummy values for the username and password which returns the false.

In the Login even click I am sending the proper values entered by the used and changing the proxy URL as below.


var store = Ext.getStore('LoginStore');
store.getProxy().url = "http://MyWeb/MyService/LoginService.svc/AthenticateUser/" + username.value + "/" + password.value;
store.load();

var result = store.proxy.reader.rawData.AthenticateUserResult;
if(result === 'Success')
{
var main = Ext.getCmp('mainmenu');
main.layout.setActiveItem(0);
}
else
{
Ext.getCmp('lblLoginErr').show();
}



But this is always returning the value from the previous request.
How can I get the values for the current request.

Please help!!!

Regards,
SivaPrasad.B

Scott Mildenberger
24 Jul 2014, 6:44 AM
store.load() is asynchronous so it is not finished when you are trying to verify the result. You can use a callback function to do the verification so that you know load() has finished. See here http://service.cnxcorp.com/ext-4.2.1/docs/index.html#!/api/Ext.data.Store-method-load