I have a php variable which has path as value.I am trying to pass this url variable to javascript function.
private function call_import_function($post_type,$fields,$fields_order,$upld_file)
{
$uploaded_file = $upld_file['file'];
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
var formdata = {
'action': 'get_csv',
'post_type' : '<?php echo $post_type;?>',
'fields' : '<?php echo $fields;?>',
'fields_order' : '<?php echo $fields_order;?>',
'uploaded_file' : '<?php echo $uploaded_file;?>',
};
$.post('<?php echo $this->ajax_url;?>',formdata, function( data ) {
console.log("Begun!!!");
}).done(function( data ) {
var obj = jQuery.parseJSON(data);
if(obj.error)
{
$("#column2").html(obj.error_msg);
}
else
{
console.log(data);
//$("#column2").html(obj.output);
}
});
});
</script>
<?php
}
But it gives me an error,
SyntaxError: malformed hexadecimal character escape sequence
'uploaded_file' : 'E:\xampp\htdocs\nick\projectWed/wp-content/uploads/2'
I have tried php functions like json_encode, urlencode with $url , but non of them provided me good solution for this. I need to solve this error...