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 7697771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:05:17+00:00 2026-05-31T22:05:17+00:00

If I return nothing to the following post, I get an AJAX parse error:

  • 0

If I return nothing to the following post, I get an AJAX parse error:

$.post('user.php', {id: 'job'}, function(data) {
    console.log(data.length);
},'json');

How can I avoid it? I want to avoid the server giving any empty answers (like “0”) to limit bandwidth consumption (mobile app).

Thanks

  • 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-05-31T22:05:18+00:00Added an answer on May 31, 2026 at 10:05 pm

    Supporting empty responses to calls for JSON

    Remove response type declaration if you know it will differ in the code you have given:

    $.post('user.php', {id: 'job'}, function(data) {
        console.log(data.length);
    });
    

    jQuery will give you decoded JSON in data, if it receives correct JSON.

    Saving bandwidth

    You are trying to save bandwidth by removing 2 chars (like “{}” or “[]“) from the response. This may be pointless (not only because of specific carrier’s way of measuring bandwidth usage), as there is also the data sent not in the body of the response, but in its headers. Headers contain a lot of information, which includes:

    • cache information,
    • content type,
    • server software information,
    • cookie data,
    • plus non-standard headers for various purposes,

    And every header is in the following format:

    Header-Field-Name: HeaderFieldValue
    

    thus limiting number of headers sent may be orders of magnitude more efficient than avoiding two mentioned chars in the responses.

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

Sidebar

Related Questions

I am doing the following: <script type=text/javascript> $(function(){ $(#ipad).submit(function() { $.post(ipadcheck.php, $(#ipad).serialize(), function(data) {
Hey, I've tried researching how to POST data from java, and nothing seems to
I have the following code: <form action= method=get onsubmit=doRequest($('word').value); $('word').value=''; return false;> <input type=text
I want to return nothing when if condition is not met, for instance (if
echo timezone_name_from_abbr(, 3600*7, 0); //ok echo timezone_name_from_abbr(, 3600*8, 0); //NOT ok! return nothing! echo
What does array_search() return if nothing was found? I have the need for the
huh? google returns nothing on what this error is... All I am doing is
What if there is nothing that matches the get? Then it returns in an
return false seems to work in the submitHandler but I'm not sure why. function
I have the following php object(??? new to this). It is being sent through

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.