You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2017/11/12 23:41:13 UTC

[GitHub] justinmclean opened a new issue #70: JSON parse error on HTTPService when URL not found

justinmclean opened a new issue #70: JSON parse error on HTTPService when URL not found
URL: https://github.com/apache/royale-asjs/issues/70
 
 
   Example code:
   ```
   <?xml version="1.0" encoding="utf-8"?>
   <js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:js="library://ns.apache.org/royale/basic"
                   applicationComplete="init()">
   
       <fx:Script><![CDATA[
           import org.apache.royale.net.HTTPService;
   
           public var load:HTTPService = new HTTPService();
   
           public function init():void {
               load.url = "text.JSON";
               load.addEventListener("complete", loadedJSON);
               load.addEventListener("ioError", errorJSON);
               load.addEventListener("communicationError", errorJSON);
               load.addEventListener("httpStatus", httpStatus);
               load.send();
           }
   
           public function loadedJSON(event:Event):void {
               var json:Object = load.json;
           }
   
           public function errorJSON(event:Event):void {
                 console.error("JSON error");
           }
   
           public function httpStatus(event:Event):void {
                 console.error(load.status);
           }
           ]]></fx:Script>
       
       <js:valuesImpl>
           <js:SimpleCSSValuesImpl/>
       </js:valuesImpl>
   
       <js:initialView>
           <js:View>
               <js:Label text="Hello World" />
           </js:View>
       </js:initialView>
   
   </js:Application>
   ```
   
   When run (on Chrome) this will first show this exception:
   HTTPService.js:191 GET file:///Users/justinmclean/IdeaProjects/FlexJSTest/target/javascript/bin/js-debug/text.JSON net::ERR_FILE_NOT_FOUND
   
   And then this one:
   ```
   Uncaught SyntaxError: Unexpected end of JSON input
       at JSON.parse (<anonymous>)
       at org.apache.royale.net.HTTPService.get__json (HTTPService.js:383)
       at Example.loadedJSON (Example.js:115)
       at org.apache.royale.net.HTTPService.goog.events.EventTarget.fireListeners (eventtarget.js:284)
       at Function.goog.events.EventTarget.dispatchEventInternal_ (eventtarget.js:381)
       at org.apache.royale.net.HTTPService.goog.events.EventTarget.dispatchEvent (eventtarget.js:196)
       at org.apache.royale.net.HTTPService.org.apache.royale.events.EventDispatcher.dispatchEvent (EventDispatcher.js:73)
       at org.apache.royale.net.HTTPService.org.apache.royale.core.ElementWrapper.dispatchEvent (ElementWrapper.js:221)
       at org.apache.royale.net.HTTPService.progressHandler (HTTPService.js:208)
   org.apache.royale.net.HTTPService.get__json @ HTTPService.js:383
   Example.loadedJSON @ Example.js:115
   goog.events.EventTarget.fireListeners @ eventtarget.js:284
   goog.events.EventTarget.dispatchEventInternal_ @ eventtarget.js:381
   goog.events.EventTarget.dispatchEvent @ eventtarget.js:196
   org.apache.royale.events.EventDispatcher.dispatchEvent @ EventDispatcher.js:73
   org.apache.royale.core.ElementWrapper.dispatchEvent @ ElementWrapper.js:221
   org.apache.royale.net.HTTPService.progressHandler @ HTTPService.js:208
   ```
   
   None of the event handler are called including httpStatus (except complete).
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services