You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Joe Bowser (JIRA)" <ji...@apache.org> on 2013/05/13 19:09:17 UTC

[jira] [Commented] (CB-3379) Incorrect way of trying to XHR the cordova_plugins.json file

    [ https://issues.apache.org/jira/browse/CB-3379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13656123#comment-13656123 ] 

Joe Bowser commented on CB-3379:
--------------------------------

We don't use jetty or any other server, so there will be no http status.
                
> Incorrect way of trying to XHR the cordova_plugins.json file 
> -------------------------------------------------------------
>
>                 Key: CB-3379
>                 URL: https://issues.apache.org/jira/browse/CB-3379
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaJS
>    Affects Versions: 2.7.0
>            Reporter: Ilya
>            Assignee: Filip Maj
>
> Frankly, I don't like the way you are trying to XHR the cordova_plugins.json file asynchronously (*lines 6811-6831 in cordova-2.7.0.js*).
> Why there is no check:
> {code:title=cordova-2.7.0.js|borderStyle=solid}
>   xhr.onload = function() {
>     if (xhr.readyState === 4) {
>       if (xhr.status === 200) {
>         ....
>         handlePluginsObject(obj);
>       } else {
>         finishPluginLoading();
>       }
>     }
>   }
>    ....
> {code}
> For instance, if there is no cordova_plugins.json jetty server will send a responce with the following responceText:
> {code:xml} 
> "<html>
> <head>
> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
> <title>Error 404 Not Found</title>
> </head>
> <body>
> <h2>HTTP ERROR: 404</h2>
> <p>Problem accessing /cordova_plugins.json. Reason:
> <pre>    Not Found</pre></p>
> <hr /><i><small>Powered by Jetty://</small></i>
> </body>
> </html>"
> {code}     
> And JSON.parse will throw "*SyntaxError: Unexpected token <*", which won't be caught - app will crash                                 
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira