简体   繁体   中英

Is JSON sent through AJAX formmated as XML at somepoint?

So AJAX calls the xmlhttprequest and I'm wondering if somewhere in the pipeline JSON or other text gets formatted to XML even if it didnt start out that way. It looks like no using dev tools but maybe chrome is converting it for me?

XMLHttpRequest is a general protocol for asynchronous data transport between web-browser and server. As such, it's agnostic to the format in which your data is sent.

It could be sent and/or received in JSON, XML, clear text, or any other format.

Is it possible that, in your case, the text is transformed server-side? YOu should be able to, through Chrome Dev Console, see exactly what data is sent and received from your web-browser. If the response is not in the format that you expect the conversion is happening server-side.

For more information on XMLHttpRequest, I recommend reading Mozilla's excellent documentation: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest

Simple answer is no. It shouldn't. The type of content in request/response if specified with special headers:

Accept: application/json
Content-Type: application/json

You will see these headers while looking at the request/response. If implemented, server and client will be ok with end-to-end JSON communication, if not implemented, one of them will have to parse/format to an accepted format.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM