+1 vote
in AJAX by
What do I do on the server to Interact with an Ajax Client?

1 Answer

0 votes
by

In servlets, this could be completed if the use of the HttpServletResponse.setContentType()need to be set to “textual content/xml” whilst the go back kind is XML. Many XMLHttpRequest implementations will bring about any mistakes if the “Content-Type” header is ready The code underneath indicates a way to set the “Content-Type”.

reaction.setContentType("textual content/xml");

reaction.getWriter().write("invalid");

You may need to set whether or not or now no longer to set the cache header for instances inclusive of autocomplete wherein you would need to inform proxy servers/and browsers now no longer to cache the results.

reaction.setContentType("textual content/xml");

reaction.setHeader("Cache-Control", "no-cache");

reaction.getWriter().write("invalid");

Note to the developer: Internet Explorer will mechanically use a cached end result of an AJAX reaction from an HTTP GET if this header isn’t always set that can make matters hard for a developer. During improvement mode you might need to set this header. Where do I keep nation with an AJAX consumer

As with different browser-primarily based totally net programs, you’ve got got some alternatives which consist of:

On the consumer in cookies – The length is confined (usually round 4KB X 20 cookies in keeping with area so a complete of 80KB) and the content material might not be stable except encrypted. That’s hard, however now it is no longer not possible to use JavaScript.

On the consumer withinside the web page – This may be completed securely however may be elaborate and hard to paint with. See my weblog access on Storing State at the Client for extra information in this topic.

On the consumer report gadget – This may be completed if the consumer offers to get admission to the browser to put in writing to the neighborhood report gadget. Depending for your use instances this could be vital however warning is advised.

On the Server – This is toward the conventional version wherein the consumer view is of the nation at the server. Keeping the records in sync may be a chunk elaborate. Therefore, we have an answer for Refreshing Data in this. As extra statistics processing and manipulate movements to the consumer wherein the nation is saved will want to be re-evaluated.

Related questions

+1 vote
asked Nov 27, 2022 in AJAX by sharadyadav1986
+1 vote
asked Nov 27, 2022 in AJAX by sharadyadav1986
...