+1 vote
in AJAX by
Should I use Xml or Text, Javascript, or Html as a Return Type?

1 Answer

0 votes
by

It depends. The ‘X’ in AJAX stands for XML, however numerous AJAX proponents are short to factor out that not anything in AJAX, in keeping with se, precludes the use of different varieties of payload, inclusive of JavaScript, HTML, or simple textual content.

  1. HTML – Injecting server-generated HTML fragments without delay right into a file is usually a completely powerful AJAX technique. However, it is able to be complex to maintain the server-aspect aspect in sync with what’s displayed at the consumer.
  2. XML – Web Services and AJAX appear made for one any other. You can use consumer-aspect API for downloading and parsing the XML content material from RESTful Web Services. (However bear in mind with a few SOAP-primarily based totally Web Services architectures the payloads can get pretty massive and complicated, and consequently can be irrelevant with AJAX strategies.)
  3. Plain Text – In this case, server-generated textual content can be injected right into a file or evaluated through consumer-aspect common sense.
  4. JavaScript – This is an extension to the apparent textual content case with the exception that a server-aspect aspect passes a fraction of JavaScript inclusive of JavaScript item declarations. Using the JavaScript eval() feature you could then create the items at the consumer. JavaScript Object Notation (JSON), that’s a JavaScript item-primarily based totally records trade specification, is based on this technique.

Related questions

0 votes
0 votes
asked Sep 13, 2022 in JSF by sharadyadav1986
0 votes
asked Oct 7, 2019 in Android by pranay jain
...