Open theredled opened 7 years ago
Thanks for bringing this up. Any suggestions for addressing this? Perhaps using JSON.stringify?
I don't think so, it should send the data as if it was a form, in a proper querystring format...
With Jquery, it would be querystring = $.param(data);
With plain JS, you have write a recursive function using encodeURIComponent()
...
There is actually a method in the plugin that does that, ss.obj2string()
. I'll work on an update.
Maybe you could also check if data is a string, and then send it "as is" ?
That's what I was planning, only processing the input if it's not a string.
Can you test this and see if it works?
Sorry not working on PHP side!
JS Data : data: {args: 'blablabla', test: {a: 1, b: {c: 'test'}}}
POST data :
------WebKitFormBoundaryA4pVRKiPAXg3Bpl9
Content-Disposition: form-data; name="args"
blablabla
------WebKitFormBoundaryA4pVRKiPAXg3Bpl9
Content-Disposition: form-data; name="test"
a=1&b%5Bc%5D=test
should be (I guess):
------WebKitFormBoundaryA4pVRKiPAXg3Bpl9
Content-Disposition: form-data; name="args"
blablabla
------WebKitFormBoundaryA4pVRKiPAXg3Bpl9
Content-Disposition: form-data; name="test[a]"
1
------WebKitFormBoundaryA4pVRKiPAXg3Bpl9
Content-Disposition: form-data; name="test[b][c]"
test
(Because it's actually multipart and not normal POST)
From the PHP side, what is the expected result? In other words, how should the variables be accessible in PHP?
Expected result:
$_POST == array(
'args' => 'blablabla',
'test' => array('a' => 1, 'b' => array('c' => 'test'))
);
Got:
$_POST == array(
'args' => 'blablabla',
'test' => 'a=1&b%5Bc%5D=test'
);
Hi, When you put "{args:{name: 'test', address: 'test'}}" as "data" argument, it is sent as "{args:'Object [object]'}".
Also, writing a query string in "data" could be an alternative, but it doesn't work either.