JavaScript
A5.ajax.buildURLParam Method
Syntax
A5.ajax.buildURLParam(parameter,value)
Arguments
- parameterstring
The name of the parameter.
- valueAny Type array
A single value, or an array of values
Description
Builds a URL encoded query string that can be used when making an Ajax callback.
Discussion
This function can be used when creating a string of data to be passed back to the server by A5.ajax.callback(). It ensures both the parameter name and value are URL encoded.
var data = A5.ajax.buildURLParam('_name','Alpha&Beta'); //returns _name=Alpha%26Beta /* If you want multiple name/value pairs, the following pattern is often used */ var arr = []; arr.push( A5.ajax.buildURLParam('_name1','Alpha&Beta') ); arr.push( A5.ajax.buildURLParam('_name2','Alpha Beta') ); arr.push( A5.ajax.buildURLParam('_name3','Alpha+Beta') ); var queryString = arr.join('&');
The value can either be a single value:
A5.ajax.buildURLParam('value','my&text'); /* returns: 'value=my%26text'*/
or an array of value:
A5.ajax.buildURLParam('value','my&text'); /* returns: 'value=my%26text'*/
See Also