8

Possible Duplicate:
What is the correct JSON content type?

I have problem with JSON is that it is only displaying " Content-Type: text/html" I am testing on localhost and my online code is

header('Access-Control-Allow-Origin: *');

header('Content-Type: application/javascript');
//header('Content-type: text/javascript');
//header('Content-type: application/json');
2
  • why do you not use application/json? Commented Sep 30, 2012 at 7:09
  • 2
    Duplicate Commented Sep 30, 2012 at 7:13

3 Answers 3

3

You should use the application/json header for JSON data:

header('Content-type: application/json');
Sign up to request clarification or add additional context in comments.

3 Comments

@user1709424 can you post some code??
<?php require 'include/jamroom-include.inc.php'; header('Access-Control-Allow-Origin: '); //header('Access-Control-Allow-Methods: *'); //content header header('Content-Type: application/javascript'); header('Content-type: text/'); header('Content-type: application/*'); header('Content-Type: application/json'); header('Content-Type: application/x-javascript'); header('Content-Type: text/javascript'); header('Content-Type: text/x-javascript'); header('Content-Type: text/x-json');
why are you inserting this much of header only put this header header('Content-type: application/json'); for getting json output data.
1

The application/json Media Type for JavaScript Object Notation (JSON)

header('Content-type: application/json');

chech this from IANA

good read:

Application Media Types

Comments

1

The MIME type for JSON is application/json

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.