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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:56:18+00:00 2026-06-06T14:56:18+00:00

am trying send an array to php file using $_POST ,still always getting an

  • 0

am trying send an array to php file using $_POST ,still always getting an undefined variable
any idea !!

var all = [];
var textInput = $('input[type=text]');
var checkBox = $('input[type=checkbox]');
var radio = $('input[type=radio]');
textInput.each(function () {
    if ($(this).val() != "") {
        name = $(this).attr('name');
        value = $(this).attr('value');
        all[name] = value;
    }
});
checkBox.each(function () {
    if ($(this).attr("checked")) {
        name = $(this).attr('name');
        value = $(this).attr('value');
        all[name] = value;
    }
});
radio.each(function () {
    if ($(this).attr("checked")) {
        name = $(this).attr('name');
        value = $(this).attr('value');
        all[name] = value;
    }
});
var getSelect = $('#experince');
if (getSelect[0].selectedIndex != 0) {
    name = getSelect[0].name;
    value = getSelect[0].selectedIndex;
    all[name] = value;
}
$.post('test.php', all, function (data) {
    alert(data);
    $.each(data, function (key, value) {
        alert(value);
    });
}, 'json');

PHP FILE

    if(!isset($_POST['workF'])){
    $_POST['workF'] ="undefine";
}

if(!isset($_POST['workP'])){
    $_POST['workP']="undefine";

}

if(!isset($_POST['gender'])){
    $_POST['gender']="undefine";
}

if(!isset($_POST['experince'])){
    $_POST['experince']="undefine";
}

if (!isset($_POST['jobs'])){
    $_POST['jobs']="undefine";
}

if(!isset($_POST['location'])){
    $_POST['location']="undefine";

}

$work_type_f = $_POST['workF'];
$work_type_p = $_POST['workP'];
$gender = $_POST['gender'];
$experince = $_POST['experince'];
$jobs = $_POST['jobs'];
$location =$_POST['location'];

enter image description here

  • 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-06T14:56:20+00:00Added an answer on June 6, 2026 at 2:56 pm

    all should be an object, not an array:

    var all = {};
    

    jQuery will do the necessary escaping for you when passing it to $.post, but it won’t read the object properties of an array.

    However as Joy stated, you’re just trying to mimic a form here. Make sure the inputs are all contained inside a single form and use .serialize() to get a string which can be send along with a HTTP request.

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

Sidebar

Related Questions

I am trying to send an e-mail using php script but i am getting
I am trying to send across a character array using a transmitter and a
I am trying to upload a file using php,and i need to pass a
I'm trying to send a Json array over using an AJAX call to a
I'm trying to post some very simple data to a php file using jquery
Having big problems trying to get my php script to send email. Using this
I'm trying to send a file to the user using xsendfile within the code
Hi Im trying to send an array from php to my javascript. Is this
Im trying to send an array of checkboxes (value) to PHP via jquery. How
I am trying to send an array of this struct to a DBus Server:

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.