My .net MVC action is going to respond to ajax requests (jquery).
Do I (or should I) set the document type of my header?
I will be responding with either just html/plain text or maybe even JSON.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If it’s responding with html/plain text use:
If it’s responding with JSON use:
It is good practice to do so, although it really depends on what you’re doing with the responded data.
Sometimes JavaScript frameworks will automatically work the response depending on the Header. For example PrototypeJs automatically
sanitizesandevals the response if it has ‘application/json‘ header.