I have a problem with slashes! I have some jQuery for handling generic dialogs on a page. In some cases the fields are passing /-delimited paths...
var fieldValues = [];
// pull values from all the fields belonging to the dialog...
$.each($(this).find('input, textarea, select'), function(n,field) {
// escape the path fields
var value = escape($(field).val().replace(/\//g,'__slash__'));
//alert ($(field).attr('id')+'='+value);
if(id != '' && value != '') {
fieldValues.push(id+'='+value);
}
});
This code works, but I have a manual stripping out of __slash__ when I get to the php end of things. Is there some encoding function I'm missing that would let me drop the clumsy-looking replace?
You can use Javascript's built-in encodeURIComponent()
and then PHP's rawurldecode()
should decode it in PHP once received.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With