blackberry / WebWorks

BlackBerry WebWorks for Smartphones is a platform for building deeply integrated web applications for BlackBerry smartphones
http://developer.blackberry.com/html5
268 stars 51 forks source link

Uncaught SyntaxError: Unexpected end of input #127

Closed rodnolan closed 11 years ago

rodnolan commented 11 years ago

Environment Details BB10 OS Version 10.0.9.388 BB10 WebWorks SDK 1.0.2.9 My app also uses jQuery 1.8.1 and bbUI 0.9.4

Error Details At application startup, the following error is thrown from line 1178 of webworks 1.0.2.9.js

Uncaught SyntaxError: Unexpected end of input

request = new XMLHttpRequest();
        request.open("GET", "http://localhost:8472/extensions/get/?hash=" + wwInfo.hash + "&version=" + wwInfo.version, true);

        request.onreadystatechange = function () {
            if (request.readyState === 4) {
                resp = JSON.parse(decodeURIComponent(request.responseText));

/* Uncaught SyntaxError: Unexpected end of input gets thrown here */

                if (request.status === 412) {
                    //Application Webworks.js does not match framework, display error to user.
                    alert(resp.msg);
                } else if (request.status === 200) {
                    builder.build(resp.data).into(window);
                    //At this point all of the APIs should be built into the window object
                    //Fire the webworks ready event
                    _webworksReady = true;
                    fireWebworksReadyEvent();
                }
            }
        };
        request.send(null);

This is caused by the fact that request.responseText is an empty string, since the page below produces the same error.

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="jquery/jquery-1.7.1.min.js"></script>
    <script>
        $(document).ready(function () {
            var resp = JSON.parse(decodeURIComponent(''));
            console.log(resp);
        });
    </script>
</head>
<body>
</body>
</html>

The problem could be corrected with an empty string check or a try/catch but I'm also wondering if there's something wrong with my config.xml. For reference, here are my index.html and config.xml.

index.html

<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0,user-scalable=no,width=device-width,target-densitydpi=device-dpi"/>
    <title>My Title</title>

    <link rel="stylesheet" type="text/css" href="css/bbui-0.9.4.css"/>

    <script type="text/javascript" src="js/bbui-0.9.4.js"></script>
    <script src="js/webworks-1.0.2.9.js"></script>
    <script src="js/jquery-1.8.1.min.js"></script>

    <script src="js/utils.js"></script>
    <script>
        function ready() {
            console.log('calling bb.init from index.html');
            bb.init({
                bb10ActionBarDark : false,
                bb10HighlightColor : '#00A8DF'
            });
        }

        window.addEventListener('load', function () {
                document.addEventListener('webworksready', ready);
        }, false);

    </script>
</head>
<body onload="bb.pushScreen('splash.html', 'splashScreen')">
</body>
</html>

config.xml

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
    xmlns:rim="http://www.blackberry.com/ns/widgets"
    version="1.0.0.0"
    id="MyApp">

    <name>MyApp</name>
    <author rim:copyright="2012 My Company" email="me@mycompany.com" href="http://www.mycompany.com">My Company</author>
    <icon rim:hover="false" src="assets/images/icon.png"/>

    <content src="index.html"/>

    <rim:permissions>
        <rim:permit>access_shared</rim:permit>
        <rim:permit>bbm_connect</rim:permit>
        <rim:permit>use_camera</rim:permit>
    </rim:permissions>

    <access uri="http://api.flickr.com" subdomains="true"/>
    <access uri="http://flic.kr/p/" subdomains="true"/>

    <access uri="https://ajax.googleapis.com" subdomains="true"/>
    <access uri="http://images.google.com" subdomains="true">
        <feature id="blackberry.invoke"/>
    </access>
    <access uri="http://t0.gstatic.com" subdomains="true">
        <feature id="blackberry.invoke"/>
    </access>
    <access uri="http://t1.gstatic.com" subdomains="true">
        <feature id="blackberry.invoke"/>
    </access>
    <access uri="http://t2.gstatic.com" subdomains="true">
        <feature id="blackberry.invoke"/>
    </access>
    <access uri="http://t3.gstatic.com" subdomains="true">
        <feature id="blackberry.invoke"/>
    </access>

</widget>
nukulb commented 11 years ago

wrong repo

moved it here- https://github.com/blackberry/BB10-WebWorks-Framework/issues/289