Hello Everyone...
Im doing a little JSON assignment (pasted below whatever i've
done till now). My Flex App should hit a server (i've put in the url)
and get the 'Welcome to XYZ server' from there and display it. But Im
getting a lot of errors. I have included the core library in my
project.
Havent done any JSON stuff before,so duno wat these errors are...
PLEASE HELP....
Code here:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="getmessage.send()">
<mx:Script>
<![CDATA[
import com.adobe.serialization.json.JSON;
import mx.rpc.events.ResultEvent;
private function getMessageFromServer(event:ResultEvent):void
{
var rawData:String=String(event.result);
var msg:String = (JSON.decode(rawData) as String);
var recievedMessage:String=new String(msg);
serverMessage.text=recievedMessage;
}
]]>
</mx:Script>
<mx:HTTPService id="getmessage" method="GET" resultFormat="text"
url="http://174.129.221.212:8989/solr/" useProxy="false"
result="getMessageFromServer(event)">
</mx:HTTPService>
<mx:Panel width="250" height="200" layout="absolute" title="JSON
talks to the server!" themeColor="#229EB1" backgroundColor="#C3E4F0"
borderColor="#24F092" horizontalCenter="-9" verticalCenter="-7"
cornerRadius="8">
<mx:Label text="Hello !" id="serverMessage" x="89" y="45" width="52"
textAlign="center"/>
<mx:Button label="Click" id="getButton" x="89" y="99"
borderColor="#42DFB1" fillAlphas="[1.0, 0.6, 0.6, 0.6]"
fillColors="[#37CE7A, #EBEEDD]"/>
</mx:Panel>
</mx:Application>
=========================================================================== =================================================================
Errors here:
Error: Unexpected < encountered
at com.adobe.serialization.json::JSONTokenizer/parseError()[C:
\Development\ContractProjects\Adobe\as3corelib\src\com\adobe
\serialization\json\JSONTokenizer.as:546]
at com.adobe.serialization.json::JSONTokenizer/getNextToken()[C:
\Development\ContractProjects\Adobe\as3corelib\src\com\adobe
\serialization\json\JSONTokenizer.as:171]
at com.adobe.serialization.json::JSONDecoder/nextToken()[C:
\Development\ContractProjects\Adobe\as3corelib\src\com\adobe
\serialization\json\JSONDecoder.as:86]
at com.adobe.serialization.json::JSONDecoder()[C:\Development
\ContractProjects\Adobe\as3corelib\src\com\adobe\serialization\json
\JSONDecoder.as:63]
at com.adobe.serialization.json::JSON$/decode()[C:\Development
\ContractProjects\Adobe\as3corelib\src\com\adobe\serialization\json
\JSON.as:81]
at jsonApp/getMessageFromServer()[C:\Documents and Settings\admin\My
Documents\Flex Builder 3\jsonApp\src\jsonApp.mxml:11]
at jsonApp/__getmessage_result()[C:\Documents and Settings\admin\My
Documents\Flex Builder 3\jsonApp\src\jsonApp.mxml:18]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/
internal::dispatchRpcEvent()[C:\autobuild\3.2.0\frameworks\projects\rpc
\src\mx\rpc\http\mxml\HTTPService.as:290]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/
internal::resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc
\src\mx\rpc\AbstractInvoker.as:193]
at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects
\rpc\src\mx\rpc\Responder.as:43]
at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks
\projects\rpc\src\mx\rpc\AsyncRequest.as:74]
at DirectHTTPMessageResponder/completeHandler()[C:\autobuild
\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels
\DirectHTTPChannel.as:403]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()