Return content to client application with defined header

Asked

Viewed 73 times

1

I have an application that returns JSON content from PHP to an HTML page, but I do this without defining the header, such as, for example : header('Content-Type: application/json');, that is, in the application has no such statement.

Works normally, the browser can normally manipulate JSON with Javascript.

But one day I decided to define the header and when calling the content directly through the URL I realized that the content on the page, the source of the text, gets smaller when defining the header passing in the Content-Type the value application/json comparing if it had not defined the same or with the Content-Type displaying a different value, as if to return an HTML for example header('Content-Type: text/html; charset=utf-8');.

From this I would like to know. What is the difference in defining the header or not in a PHP application? There is some performance increase defining the header since the text changed to a different font and style when the content was JSON? Why this difference with the way the content is displayed on the screen?

  • How the requisition was made?

  • With GET and passing a small value in the parameter to identify the method to be called. But wanted to know about this difference.

  • Solved your doubt?

  • Still unresolved, you’re also curious to know?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.