var delivery_date = $("#year").val()+'-'+$("#month").val()+'-'+$('#day').val();
var delivery_time = $("#delivery_time").val();
var zone = $("#zone").val();
window.location = window.location+'/'+delivery_date + '/'+ delivery_time + '/'+ zone;
Do I need to escape the parameters in window.location = window.location...etc
zone could be something with spaces, quotes,..etc
var delivery_date = $("#year").val()+'-'+$("#month").val()+'-'+$('#day').val();
var delivery_time = $("#delivery_time").val();
var zone = $("#zone").val();
window.location = window.location+'/'+delivery_date + '/'+ delivery_time + '/'+ zone;
Do I need to escape the parameters in window.location = window.location...etc
zone could be something with spaces, quotes,..etc
Share Improve this question asked Mar 30, 2011 at 12:52 Chris MuenchChris Muench 18.4k71 gold badges218 silver badges373 bronze badges 2- 1 Do you have URL mapping, or did you mean to send those values as query string data to the same page? – user447356 Commented Mar 30, 2011 at 12:56
-
1
if you want encode url use
encodeURIComponent()
instead ofescaspe()
– Luca Filosofi Commented Mar 30, 2011 at 12:57
3 Answers
Reset to default 3You need to properly url-encode the parameters. See here for more information; encodeURIComponent
should work fine.
if you want to have the php url_encode and url_decode behaviour use:
function url_encode(str) {
str = (str + '').toString();
return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28'). replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}
function url_decode(str) {
return decodeURIComponent((str + '').replace(/\+/g, '%20'));
}
Use encodeURIComponent.
var zone = encodeURIComponent($("#zone").val());
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744353862a4570132.html
评论列表(0条)