PDA

View Full Version : Store or Model Proxy?



managedfollowup
9 Dec 2011, 12:16 PM
Hi,

Imagine a login page, user sends up a email and password, and registration details get sent back, so:

I am using a model proxy to a RESTful service at the moment. I can send data up and get the new data, but different json back. It's in the "raw" property but no luck using "set" with this data on the model, like:
model.save({
scope: this,
success: function (data, operation) {
var model2 = this.getRegisterModelModel().create();
model2.set(data.raw);
},
failure: function (records, operation) {
Ext.Msg.alert('Failure', 'Failed to login.');
}
});

Or should I use a store to do it, if so using the syc method or?
Is there a way to call a url just like you can in JQuery? guess this is a custome Proxy?
Please advice with a little code to help me along please, I am finding the Model and Store proxy confusing! cheers. Paul.

twaindev
9 Dec 2011, 12:40 PM
Have a look at Ext.Ajax (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Ajax).

managedfollowup
10 Dec 2011, 1:54 AM
Cheers @twaindev. For others, this is what you do to call a RESTful service passing Json up and DIFFERENT Json back

Ext.Ajax.request({
url: 'UserService/Login',
method: "POST",
jsonData: Ext.JSON.encode(model),
scope: this,
success: function (response) {
var responseData = Ext.JSON.decode(response.responseText);
}
});