PDA

View Full Version : Missing passed data using RestProxy



f.sauter
5 Dec 2010, 3:35 PM
Hey all,

I have a problem to use the RestProxy (http://dev.sencha.com/deploy/touch/docs/source/RestProxy.html#cls-Ext.data.RestProxy) together with a PHP backend.

JS:


...
Ext.regModel('Message', {
fields: [
{name: 'id', type: 'int'},
{name: 'text', type: 'string'}
],

proxy: {
type: 'rest',
url : 'controller.php'
}
});

var message = Ext.ModelMgr.create({text: 'My Message!'}, 'Message');
message.save();
...


PHP (controller.php):


<?
print_r($_REQUEST);
print_r($_SERVER["REQUEST_METHOD"]);
?>


Results in (Firebug output):


Array
(
[_dc] => 1291591418769
)
POST


So, the question is, where is my passed data? I hope anyone can give me a hint. Thanks in advance!

cheers

aCa
10 Dec 2010, 1:54 AM
Did you figure this out? I seem to have the same problem with the RestProxy

edspencer
10 Dec 2010, 6:14 PM
It sends it in the POST payload. You can inspect the request in firebug or web inspector to see it. Looks like you're only looking in the GET params?

f.sauter
13 Dec 2010, 12:57 AM
Hey yes i figured this out. You can have a look at the ExtJS 3.3.1 Restful example. Or just use the following example code.

Access the params on server side (php):


$raw = '';
$httpContent = fopen('php://input', 'r');
while ($kb = fread($httpContent, 1024)) {
$raw .= $kb;
}
fclose($httpContent);
$params = json_decode(stripslashes($raw));
print_r($params); //should contains the passed data decoded as array.

edspencer
13 Dec 2010, 10:09 AM
Would it help to have more options here? It's been a while since I used PHP specifically - I've forgotten the conventions there...

butr0s
26 Apr 2011, 1:35 PM
Would it help to have more options here? It's been a while since I used PHP specifically - I've forgotten the conventions there...

It'd be great to have an option to send Ajax as regular form data (key/val pairs). The framework I'm using (RingoJS) doesn't have a way to easily extract non-POST/GET parameters. The PHP solution seems kind of "hacky" as well.

brtorres
27 Apr 2011, 6:59 PM
I'm having the same problem!
Using symfony 1.4 it's impossible to get the parameters, even when I see in chrome that they are sent in the request payload.
Why aren't these params send as $_POST???

Fortunately, the code above works! I don't even know what it does, but it works
thank you very much