Hello,
I'm new to Kendo UI framework but i have some experience with jQuery / AJAX.
I have problem with submiting value from my JS script to php file (simple AJAX works fine).
Here are my both php and js code.
Without posting data it works fine (I tried with one-funciton-only php file). But in php file i have Switch function, every time my usersModel.php is requested i POST operationCode. When operationCode =="showUsers", showUsers function should be called, when I POST "showLogs" showLogs funciton in PHP file should be called.
In Chrome Console im getting this error: Uncaught TypeError: Cannot read property 'slice' of null.
There is my php code:
Of course db,host and other variables are defined properly.
I hope someone here is able to help me. And sorry for my !perfect English ;)
Best regards.
I'm new to Kendo UI framework but i have some experience with jQuery / AJAX.
I have problem with submiting value from my JS script to php file (simple AJAX works fine).
Here are my both php and js code.
var userList = new kendo.data.DataSource({
transport: {
read: {
url: "php/usersModel.php",
dataType: "json"},
data: {operationCode:"showUsers"},
type: "post"
},
pageSize:10
});
In Chrome Console im getting this error: Uncaught TypeError: Cannot read property 'slice' of null.
There is my php code:
$operationCode
=
$_POST
[
'operationCode'
];
$conn
=
new
MySQLI(
$host
,
$user
,
$DBpassword
,
$baza
);
if
(!
empty
(
$operationCode
))
{
Switch(
$operationCode
)
{
case
"deleteUser"
:
if
(!
empty
(
$id
))
{
deleteUser(
$id
,
$conn
,
$baza
);
}
break
;
case
"showUsers"
:
showUsers(
$conn
,
$baza
);
break
;
case
"addUser"
:
addUser(
$baza
,
$conn
,
$serializedData
,
$operationCode
);
break
;
case
"editUser"
:
editUser(
$conn
,
$baza
,
$serializedData
,
$operationCode
);
break
;
case
"showLogs"
:
showLogs(
$conn
);
break
;
}
}
function
showUsers(
$conn
,
$baza
)
{
$queryString
=
"select id,username,email,telefon,imie,nazwisko,userlevel from "
.
$baza
.
".users t1 left join user_dane t2 on t1.id=t2.userid where t1.userlevel<>9 order by t1.id"
;
$results
=mysqli_query(
$conn
,
$queryString
);
$usersResult
=
array
();
while
(
$row
=mysqli_fetch_assoc(
$results
))
{
array_push
(
$usersResult
,
array
(
'id'
=>
$row
[
'id'
],
'username'
=>
$row
[
'username'
],
'email'
=>
$row
[
'email'
],
'telefon'
=>
$row
[
'telefon'
],
'userlevel'
=>
$row
[
'userlevel'
],
'imie'
=>
$row
[
'imie'
],
'nazwisko'
=>
$row
[
'nazwisko'
]
)
);
}
echo
json_encode(
$usersResult
);
}
Of course db,host and other variables are defined properly.
I hope someone here is able to help me. And sorry for my !perfect English ;)
Best regards.