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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:16:25+00:00 2026-05-25T16:16:25+00:00

I am trying to code a error callback using php and ajax. What I

  • 0

I am trying to code a error callback using php and ajax.

What I cannot get past is, I am assinging a variable to a $_POST in PHP to check for an empty value. If empty, then trigger error message.

However, jquery is passing the post to php as carton%5B0%5D:carton%5B1%5D:.

Would php see this as an empty post? What are these numbers etc after carton? carton is actually an array. thanks

+++UPDATE+++

Why is the error triggered when the statement becomes, !empty rather than empty?.
This is the code that jquery uses to create an input from a slider change event.

for(var i = 0;i < $(this).val();i++) {
        $("#carton").append('<div data-role="fieldcontain"><label for="carton" class="ui-input-text">Enter box ' + (i + 1) + ' number:</label><input type="text" name="carton['+i+']" id="carton['+i+']" class="carton ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c" /></div>')
      }
  • 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-25T16:16:26+00:00Added an answer on May 25, 2026 at 4:16 pm

    to know whetever $_POST is empty always use var_dump function like this

    var_dump($_POST);
    

    And it might be posted as array, am not quite sure but i think arrays in ajax are like this:

    array [
    [0] => 'item',
    [1] => 'item 2'
    ]
    

    array(2) { [0]=> string(0) “” [1]=> string(0) “” }

    array(number) means the number of items in the array, {[0],[1]} means the array items IDs means you can use them like $_POST[1] and $_POST[0], => string(0) ; string is the datatype contained in this array item, (0) is the number of characters in that item.

    to check whether the POST data is empty or not, you should use empty() function.

    finally, use this to post the content you want via jquery, make sure you modify it with what you need

    $.post("test.php", { carton: "this is the content"} );
    

    also you can add more POST fields by adding

    , newfield: "this is the new field's content"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to code an all in one HTML/PHP contact from with error
I get an incomplete type error when trying to compile my code. I know
I am trying to decode JSON in php I sended using an ajax call
I'm a jQuery beginner. I'm trying to code a very simple using $.get(). The
hi im new to c# and was trying to code but getting error can
I am trying to update code via Linq, but I am getting this error:
I am getting error trying to run my asp code for executing stored proc.
I got an error today while trying to do some formatting to existing code.
I am getting an error while trying to run CFmx code on a remote
I am trying to compile the following code and i am getting the error:

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.