cancel
Showing results for 
Search instead for 
Did you mean: 

Odata Model vs Jquery Ajax

amber_garg
Active Participant
0 Kudos

There are various ways by which we can call an Odata webservice in our fiori/ui5 application  for eg. using Odata model or by using Jquery Ajax.

Which of the method is preferred in different circumstances and what are the advantages/disadvantages which needs to be considered while deciding the approach.

Regards

Amber

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The UI5 models use jQuery.ajax themselves which you can see if you delve into the .js files (e.g. resources\sap\ui\model\json\JSONModel.js).

The main advantage to using a model is that it holds your data and you can bind your UI5 controls to it - suggest you check out this link for more informationhttps://sapui5.netweaver.ondemand.com/sdk/#docs/guide/Introduction.1.html

There may be certain situations where you would want to use your own jQuery.ajax call, for example posting data from your application to a web service.

all Model which is introduced in sapui5 internally use same concept as jQuery Ajax.

1. jQuery Ajax is a hard coded process. Via this checking return data type, Accordingly Parsing and Binding of data is your responsibility.

2. Using Model is beast practice when you know your services return data  type,According that you can bind directly and use it.

Answers (2)

Answers (2)

former_member182862
Active Contributor
0 Kudos

HI Amber

sap.ui.model.odata.ODataModel shall be the model to use when your UI needs to interact with oData service. It is very difficult to "talk" to the oData service with jQuery.ajax. The sap.ui.model.odata.ODataModel provides you with the necessary functions.

If the service is not oData based, then we have to discuss more.

Thanks

-D

karthikarjun
Active Contributor
0 Kudos

Hi Amber,

ODATA Model is preferable.

1. OData protocol is that it is becoming an OASIS standard

2. Next version of the OData protocol (v4) it is planned to support delta queries as part of the standard

3. Use OData models instead of normal Ajax calls. Odata Models are tightly integrated to the UI5 controls also. When the data changes, all the controls will be updated automatically.

Thanks,

Karthik A