JSONP HTTP type response header

What should be the value of the header of the http type of content if the body of the message is JSONP. application / javascript?

+6
source share
2 answers

Depends on the actual contents. This means the header is Content-Type .

So, if you are writing a JS callback function for the body, then yes, that should be application/javascript .

Or, if you write a JSON string to the body, then no, it should be application/json .

+14
source

If you want ajax to work for the case when you have a field to upload a file in the form as part of the input and you are not using XHR2, it should be "text" or "text / html" and you need to surround it with fake HTML an element. See the jquery forms ajax support doc for all the nasty details.

0
source

Source: https://habr.com/ru/post/892276/


All Articles