|^ Web services||Json »|
Although Ajax means an XML response (X in AJAX), it is commonly used with other formats.
Depending on the client waiting either responseText or responseXml of an XmlHttpRequest, you should use differents jelix response types.
- for any generic XML content, you will usejResponseXml
- for json encoded content, you will usejResponseJson
- for html fragments, beware you must NOT use jResponseHtml, but jResponseText (see example below).
- Generally, jResponseText is the response of choice.
Sending HTML fragments ¶
You can't use jResponseHtml as it always generates a full well-formed HTML with <html>,<head> and <body>... This is not what we want within an AJAX transaction.
jResponseText will serve your needs here :
$rep = $this->getResponse('text'); $rep->content = '<p>new data</p>'; return $rep;
Note about the use of jforms in an ajax response ¶