I have a function that takes a country name and passes it to a processing page via the load() function.
In the following example the country is "American Samoa"
function loadRates(oArg) {
var Destination = oArg.Destination.toString() || '';
alert(Destination); // Alerts "American Samoa"
var uniqueid = new Date().getTime();
$('#divRates2').html('<img src="/images/ajax-loader.gif">').load('inc_rates_output.cfm?Destination=' + Destination + '&uniqueid=' + uniqueid);
}
However, the processing page (inc_rates_output.cfm) receives the Destination url variable as "American", ie without the "Samoa".
Any ideas appreciated.
Use 'encodeURI(Destination)'
in url.
The specification for URLs ( RFC 1738 , Dec. '94) poses a problem, in that it limits the use of allowed characters in URLs to only a limited subset of the US-ASCII character set:
...Only alphanumerics [0-9a-zA-Z], the special characters "$-_.+!*'()," [not including the quotes - ed], and reserved characters used for their reserved purposes may be used unencoded within a URL.
try this: you can pass your parameters to load as an object, and let jquery do the encoding for you.
function loadRates(oArg) {
var Destination = oArg.Destination.toString() || '';
alert(Destination); // Alerts "American Samoa"
var uniqueid = new Date().getTime();
$('#divRates2').html('<img src="/images/ajax-loader.gif">').load('inc_rates_output.cfm', {"Destination" : Destination, "uniqueid" : uniqueid});
}
您需要将Destination
传递给escape函数
escape(Destination)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.