Hi everybody,
I'm a rookie in web engineering, especially with frontend & AJAX.
I send an request on the client-side per AJAX (Y.io) and want to answer him on the server-side, by sending data in JSON-format as response.
At the moment i'm doing this by having a template like this, calling it with ac.done({ foobar: foobar}):
{
{{#foobar}}
"{{key}}": {{value}},
{{/foobar}}
"": ""
}
which is imo really ugly, specially the last line to fulfill the JSON requirements.
My question: How can I send plain JSON data as response of an AJAX call?
PS: By sending data from the client to the server, I can send the js-object directly, unless it has nested object - than I can't access the keys/values of the nested object, I have to parse the object into a JSON string. Is that a XMLHttpRequest constraint?