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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:01:14+00:00 2026-05-28T13:01:14+00:00

This is the jQuery code i’m using to send the form details to a

  • 0

This is the jQuery code i’m using to send the form details to a php function:

jQuery(document).ready(function($) {    
    jQuery('.submit').click(function(){
        var str = $("#ajaxForms").serialize();
        var data = {
            action: 'myajax-submit',
            serialize: str,
            beforeSend: function(){
                alert('Sending...');
            }
        };  
        jQuery.post(MyAjax.ajaxurl, data,  function(response) {
            alert('Got this from the server: ' + response);
        });
        return false;   
    });
});

and this is the php function:

function myajax_submit() {
    $whatever = $_POST['serialize'];
    echo $whatever;
    die(); 
}

Everything works, but when the alert box appears the text displays a string of values from my html form #ajaxForms. I believe this is because the php function echos the $_POST['serialize'].

In my form i have an input box such as:

<input id="postID" name="postID" value="First Name" type="text" />

but when i try echo the $_POST['postID'] variable in the php it doesn’t display anything in the alert box.

I thought by sending the form data serialized to the php function i could use the $_POST variable associated with the form inputs?

Help appreciated. 🙂

  • 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-28T13:01:15+00:00Added an answer on May 28, 2026 at 1:01 pm

    By serializing the form inputs with jQuery’s serialize you create a string like:

    a=1&b=2&c=3&d=4&e=5&postID=10
    

    In order to get the postId you need to de-serialize the $_POST[‘serialize’]. In order to do so you should do something like:

    parse_str($_POST['serialize'], $whatever);
    

    Now on $whatever['postID'] is what you are searching for.

    Edit: Fixing parse_str() 🙂

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

Sidebar

Related Questions

In this jquery code: $(document).ready(function(){ $list = $(.channeList li); $list.click(function(){ var $this = $(this);
I have this jquery code : $(document).ready(function() { $('div.badge_button > .more').click(function() { var id
Using this jquery code: <a href=javascript:void(0) id=m1>Get Selected id's</a> jQuery(#m1).click( function() { var s;
On document ready I run this code: jQuery(document).ready(function(){ jQuery('#button').click(function() { jQuery('#contact_form').load(/Users/mge/Downloads/jquery-ajax-1/readme.txt); return false; });
I have a problem with this jQuery code: $(document).ready( function(){ alert($('#search').val()); var dummyInput =
I have this jquery code: $(document).ready(function() { function slideSwitch() { var $active = $('#slideShow
Why doesn't this jQuery code work? $(document).ready(function () { $('currentPage').click(function() { $('myaccount').slideDown('slow', function() {
Trying to replace this jquery code with some php server side magic: $(document).ready(function() {
This jQuery code response with undefined why ?? function YouTube2() { $(document).ready(function(){ var txt=;
I have this jQuery code: <script type=text/javascript> $(document).ready(function() { $('.vote_up').click(function() { alert ( test:

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.