I have the following Request.JSON in my clientside (notice the conversion to a JSON string with MooTools’ own JSON parser):
var data = {action: 'delete', data: { id: item} };
data = JSON.encode(data);
var aRequest = new Request.JSON({
onSuccess : (function(json) {
...
}).bind(this),
onFailure : (function(e) {
...
}).bind(this),
onError : (function(text, error) {
...
}).bind(this),
url : "../sd_delete.php",
method : "post",
data: data,
urlEncoded: false
});
aRequest.setHeader('Content-Type', 'application/json; charset=utf-8');
aRequest.send();
Now, on the server side, both $_REQUEST and $_POST are empty arrays. How do I access the string I sent with Request.JSON? Or is there something flawed in my clientside approach?
Thanks
EDIT: Just found out that, even if I send the data as an object (without JSON.encode), there is no POST data on the server side. GET works. Might be a serverside problem?!
Following should work.
You’ll then receive post data as following in php: