url encoding using Flex navigatetoUrl function

16,095

Solution 1

Use encodeURIComponent() to encode each parameter.

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

Solution 2

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);
Share:
16,095
cdugga
Author by

cdugga

Developer, focused mainly on writing JEE applications but interested in all aspects of software engineering especially data science and AI programming.

Updated on June 11, 2022

Comments

  • cdugga
    cdugga almost 2 years

    I want to post data to a URL on my server from a Flex app. im using the following

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

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

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