Reputation: 18318
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
Upvotes: 1
Views: 11453
Reputation: 437386
You need to properly url-encode the parameters. See here for more information; encodeURIComponent
should work fine.
Upvotes: 3
Reputation: 9121
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'));
}
Upvotes: 1
Reputation: 11457
Use encodeURIComponent.
var zone = encodeURIComponent($("#zone").val());
Upvotes: 0