php - Datatables remove backslash(\) characters from data -


this codes use datatables jquery plugin send data via ajax server:

$('#alllessonattachmentstable').datatable({     processing: true,     serverside: true,     "bsort": false,     "responsive": true,     ajax: {         url: 'http://lms.dev/admin/getfileslist',         data: function (d) {             d.id = '8',             d.type = 'app\lesson'         }     },     columns: [         {data: 'checkbox', name: 'checkbox', "width": "20px"},         {data: 'picture', name: 'picture', 'classname': 'text-center'}     ] }); 

as see, type parameter sent server contain \ (backslash) character. when retrieve in laravel back-end backslash character removed.

what problem , why removed?

javascript has \ escape character. might need use \\ escape it. change code to:

d.type = 'app\\lesson' 

in console itself, can see how javascript treats \ , \\:

enter image description here

if whole thing generated php, may try using php's function addslashes() generate string friendly output.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -