Rest API and XmlHttpRequest status

Rest API and XmlHttpRequest status

Thursday 23 June 2011 3:07:57 am - 2 replies

Author Message

André R.

Thursday 23 June 2011 4:05:27 am

Try using jQuery/YUI perhaps? Or at least debug it using Firebug/Developer tools -> Network.
I'm assuming url in code example got modified by this forum as having a tag inside url would not work. 

Some nitpicks:

- Your writing to the DOM on every readystate callback, probably causing rendering reflows on every call.
- 'dyn' is now a global variable
- This will not work in IE 6, it does not have XMLHttpRequest object but an ActiveX object instead
- I think you need to define xhr.onreadystatechange after xhr.open, but most people have have moved on to use libs for these things by now so not sure anymore. 

 

If you absolutely have to code against pure javascript, try taking stuff from here maybe:
https://github.com/ezsystems/ezoe/blob/master/design/standard/javascript/ezoe/ez_core.js#L774

Good luck ;)

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Emmanuel Bichet

Thursday 23 June 2011 5:21:08 am

Thank for your answer André, but my code was just an example. I've also tried Jquery and the result is the same :

- the readystate is 4 (whitch mean the REST api is sending something)
- the status of the response is 0 (200 is expected normally)
- the responseText is empty (the json format of content/node/2 is expected)

I've check the php code in kernel/private/rest. The code make an intensive use of eZ/zeta components MvcTools. The response is created by the MvcResult class. When this class is instanciated, the status properties is set to 0. I think this is the problem. May be there is some change to do in the rest.ini settings...

You must be logged in to post messages in this topic!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.