odata.request to check readyState

May 3, 2012 at 3:02 AM

Hi all,

Is it possible to check the readystate of an Odata.request?

What I need to do is to check if the post request is ready then only I proceed on doing the rest.

My code is as bellow.


OData.request( request,
            function (data, response) {
                //Success Callback 
                if(response.readyState == 4){
                    addTimeCallBackParse(data, entryMessageCount);
            function (err) {
                //Error Callback:


when I tried to allert response.readyState it comes out as Undefined. Can someone please help me.


Thank you

May 3, 2012 at 4:29 AM

Hi Bluryone,

   That is because the response object datajs passes to the callback is not an XmlHttpRequest object and it doesn't have the readyState property...   Actually you don't need to worry about the readyState and other XHR details in the OData.request method... The library takes care of this for you and it is guaranteed that the success and error callbacks are going to be called only when the XHR completes and its readyState === 4.    In the code above, if you remove the if(response.readyState) and just live the call to your addTimeCallbackParse function everything should be fine.


Alex Trigo.

May 4, 2012 at 7:31 AM

Hi atrigo,


Thanks for the advice.

Yes I found out that the posting was sucessful however the processes which are done in the service backend is the problem.