I am trying to pass a jquery string to my cakephp controller but I keep getting an error saying json_decode expects a string but is passed an array.
Here is the code for my ajax:
var str = 'Data that i need';
var jsonString = JSON.stringify(str);
$.ajax({
type: "POST",
url: "http:/Configs/",
cache: false,
datatype: 'json',
data: {data : jsonString},
timeout: 100000,
success: function(data)
{
alert('Ok');
}
});
and in my controller im trying to recieve the data like so:
$value = json_decode($_POST['data']);
but im getting the error stated above any idea how to solve this would be great thanks.