Url encoding using Flex function navigatetoUrl

I want to send data to the URL of my server from a Flex application. im using the following

UrlParam = UrlParam + '&name='+ name.text + '&business=' + buisness.text; navigateToURL(new URLRequest(UrlParams),'_self'); 

im problem, however, is that if I enter the business with an ampersand ("A & b.com"), then the name does not send.

Does Flex have anything out of the box to encode from & to %26 ?

+4
source share
2 answers

Use encodeURIComponent () to encode each parameter.

 UrlParam = UrlParam + '&name=' + encodeURIComponent(name.text) + '&business=' + encodeURIComponent(buisness.text); navigateToURL(new URLRequest(UrlParams),'_self'); 
+7
source

use URLVariables :

 var urlRequest : URLRequest = new URLRequest("http://...."); var urlVar: URLVariables = new URLVariables(); urlVar.name = name.text; urlVar.business = buisness.text; urlRequest.data = urlVar; navigateToURL(urlRequest); 
+4
source

All Articles