Tuesday, August 12, 2008

Calling PHP page in Flex and binding to combobox

using HTTPService components, you can call php page. The php page response to flex, sends the result in the form of xml.

E.g.,

1) Use this code to call a php page
mx:httpservice id="xmlRPC" url="http://localhost/PHP/GetCountry.php" />

2) Use this code to bind the result to combobox:
mx:combobox id="Country" prompt="Select" width="210" y="177" x="125" dataprovider="{xmlRPC.lastResult.Country.CountryDetails}" labelfield="CountryCode"/>

The GetCountry.php response should be like this:

country>
countrydetails>
countrycode>US
/countrydetails>
countrydetails>
countrycode>IN
/countrydetails>
/country>

No comments: