Sunday, March 28, 2010

Problems in HTTPService with PHP

Hi,

This is the Flex code that I have-

%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:Application xmlns:mx=''http://www.adobe.com/2006/mxml'' layout=''absolute'' creationComplete=''do_work()''%26gt;
?
?%26lt;mx:HTTPService id=''find_college'' fault=''errorhandler(event)'' result=''resulthandler(event)'' showBusyCursor=''true'' method=''GET''?useProxy=''false'' %26gt;
?
?%26lt;/mx:HTTPService%26gt;
?
?
?%26lt;mx:Script%26gt;
?
?%26lt;![CDATA[
?
?import mx.collections.ArrayCollection;
?import mx.rpc.events.ResultEvent;
?import mx.controls.Alert;
?import mx.rpc.events.FaultEvent;
?
?
?[Bindable]private var collegeData:ArrayCollection = new ArrayCollection();
?
?
?private function do_work():void
?{
?find_college.url=''http://localhost/take2.php?name=pqr''
?find_college.send();
?}
?
?
?private function errorhandler(e:FaultEvent):void
?{
?Alert.show(e.fault.message,''Server Error'');
?}
?
?
?
?
?private function resulthandler(e:ResultEvent):void
?{
?collegeData = e.result.mydata;
?
?}
?]]%26gt;
?%26lt;/mx:Script%26gt;
?%26lt;mx:ComboBox id=''college_list'' x=''464'' y=''229'' dataProvider=''{collegeData}'' labelField=''name''%26gt;
?%26lt;/mx:ComboBox%26gt;
?
?
?
%26lt;/mx:Application%26gt;

-----

and the take2.php contains-

echo(''%26lt;mydata%26gt;''.$_GET['name'].''%26lt;/mydata%26gt;'');

---

Problem is that the ComboBox does not fill with the value of the GET variable, it says transferring from localhost indefinitely.

Problems in HTTPService with PHP

try changing your php code as:


Accidently hit enter , my bad.

%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:Application xmlns:mx=''http://www.adobe.com/2006/mxml'' layout=''absolute'' creationComplete=''do_work()''%26gt;

?%26lt;mx:HTTPService id=''find_college''
fault=''errorhandler(event)''
result=''resulthandler(event)''
resultFormat=''xml''
showBusyCursor=''true''
method=''GET''?
useProxy=''false'' %26gt;
?%26lt;/mx:HTTPService%26gt;
?
?
?%26lt;mx:Script%26gt;
?%26lt;![CDATA[
?
?import mx.collections.ArrayCollection;
?import mx.rpc.events.ResultEvent;
?import mx.controls.Alert;
?import mx.rpc.events.FaultEvent;
?
?[Bindable]private var collegeData:XMLList = new XMLList();
?
?private function do_work():void
?{
?find_college.url=''http://localhost/take2php?name=pqr''
?find_college.send();
?}
?
?private function errorhandler(e:FaultEvent):void
?{
?Alert.show(e.fault.message,''Server Error'');
?}
?
?private function resulthandler(e:ResultEvent):void
?{
?collegeData = XML(e.result).mydata;
?}
?]]%26gt;
?%26lt;/mx:Script%26gt;
?%26lt;mx:ComboBox id=''college_list'' x=''464'' y=''229'' dataProvider=''{collegeData}'' labelField=''name''%26gt;
?%26lt;/mx:ComboBox%26gt;
%26lt;/mx:Application%26gt;

/* ------------------------------------------------------------------------------- ---------------------*/

/* take2.php

/* ------------------------------------------------------------------------------- ---------------------*/

%26lt;?php
$x?= ''%26lt;?xml version=\''1.0\'' encoding=\''utf-8\'' ?%26gt;'';
$x .= ''%26lt;xmlbody%26gt;'';
$x .= ''%26lt;mydata%26gt;''.$_GET['name'].''%26lt;/mydata%26gt;'';
$x .= ''%26lt;mydata%26gt;''.$_GET['name'].''%26lt;/mydata%26gt;'';
$x .= ''%26lt;mydata%26gt;''.$_GET['name'].''%26lt;/mydata%26gt;'';
$x .= ''%26lt;/xmlbody%26gt;'';

header(''Content-Type: text/xml'');
header(''Content-Length: ''.strlen($x));
print($x);

Thanks for the last post, it worked

No comments:

Post a Comment