Closed zooshme closed 11 years ago
like this?
<data>
<parent>
<child>foo</child>
<child>bar</child>
</parent>
</data>
will output:
{"data":{"parent":{"child":["foo","bar"]}}}
Cool. Thanks
I'm trying to get the results from submitting to an event attached to an api page but the event's results is always empty. Is it because events cannot be attached to API Pages?
Should I open a new issue?
this should actually work as expected
Ok. I may be doing something wrong then. I'll have a closer look.
just did a quick check. It works as expected.
I've realised what I am doing wrong. I'm not sending the action[name-of-event] as part of the serialized data to the API Page. Do you know how could I do that?
are you trying to redirect the action from a form submission to the api-page?
yes
if it's so, make sure the event is only attached to the api-page and not to the page that holds the submitting form
but that's not related to this extension. Apipage doesn't intercept logic. It just hooks into the very last moment before symphony is printing out the rendered page content.
You're right for some reason the serialized data does not contain the action[event-name] = Submit key-value pair.
I've included a hidden field with the name action[event-name] and value Submit. This seems to work.
wouldn't it be a more common approach to intercept the form submission and start an ajax post request instead? Just wondering
That's what I'm doing but I don't know why when I serialize the form the action[event-name] does not get included. Probably because it's on a submit input type
jquery, right? serialize doesn't include submit buttons
yup. jquery.
Thank you so much for your help Thomas.
you're welcome
Thanks for this extension. Saves me a lot of work.
I was wondering is there a way to output json arrays?