Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8705045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:15:25+00:00 2026-06-13T03:15:25+00:00

My server is sending data to the client. header(‘Content-type: application/json’); echo json_encode($jsondata); What is

  • 0

My server is sending data to the client.

header('Content-type: application/json');
echo json_encode($jsondata);

What is the benefit of the header? It encodes the data, but doesn’t appear to have any visual effects in the various browsers that I tested it. I’ve also seen it break a fileupload plugin (Valum’s I think but don’t recall). Lastly, if my server is only returning true/false (or 1/0, or success/null), should I still encode the response?

So, to recap my question, when and why should Content-Type be application/json?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:15:27+00:00Added an answer on June 13, 2026 at 3:15 am

    Simple: the content-type should be application/json whenever you’re serving JSON data. It’s just a matter of declaring the data properly, like having the right license plates on your car or an ingredients list on a bag of chips.

    Whether there is a visual representation of the data in the browser is another issue, that’s not the main reason why you serve a content type. (I know of no browser that shows a nice tree view for JSON data. It would be nice though!)

    Lastly, if my server is only returning true/false (or 1/0, or success/null), should I still encode the response?

    It depends on what the client expects, but the best policy is usually to be consistent in what you output, i.e. always JSON encode it if your other services use JSON encoding as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote c# client-server application, server is sending data using socket.send(byte[]) and receive using
I have an EventMachine server sending TCP data down to a Mac client (via
If a TCP connection is established between a client and server, is sending data
How can I stop sending data to the server if the button allready has
I am having a weird problem with sending data back to my server. This
I'm sending some data to an external URL using Curl. The server sends me
The server is sending a list of urls of images when the application loads.
Sending XML from C# Server and receiving it it in Android Java client This
When sending uncontrolled amounts of TextWebSocketFrames to a simple Netty WebSocket echo server implementation
I currently have a client / server setup where the client sends data to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.