Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do I ignore MIME types in ajax calls? The response header passes a JSON obje

ID: 3716403 • Letter: H

Question

How do I ignore MIME types in ajax calls?

The response header passes a JSON object, but it also passes the MIME type ("Content-Type", 'application/json');

JSON.parse(object) fails because the following MIME type is there. If I remove the MIME type and just pass the JSON object JSON.parse(object) works. But, that doesn't solve my issue. I need to be able to ignore MIME types in case someone adds it. How do I do that within an ajax call that has a condition JSON.parse(object) to see if its valid JSON.

Explanation / Answer

To tell the server what datatype we ajax is expecting in response, we need to use dataType keyword. So use below flag in your ajax call

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote