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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:18:39+00:00 2026-05-22T17:18:39+00:00

Ok somehow im having the hardest time figuring this out so i want to

  • 0

Ok somehow im having the hardest time figuring this out so i want to do an call ajax with a form and im using jquery to serialize it with .serialize(). The data being sent to php looks something like this

key1=value&key2=value2&key3=value3

And im using a post request. It looks simple enough, but somehow im having a really hard time figuring out how to access these key/value pairs, i cant use explode() on & because that will give me

[0] => key1=value1
[1] => key2=value2
[2] => key3=value3

and i cant use $_POST[‘key1’] or $_GET[‘key1’] in php to access these values. What should i do!!! Thanks

And as a side question i notice .serilize() replaces line breaks with %0A and white spaces with +, how do i decode these values with php? Thanks again!

Edit:

Hey well the jquery code is fairly basic its :

var formSubmit = $(this).serialize();
$.post('ajax.php',{"formSubmit": "true", "formInfo": formSubmit}
  • 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-22T17:18:40+00:00Added an answer on May 22, 2026 at 5:18 pm

    If you’re submitting the form data with jQuery’s Ajax functionality, there should not be a problem with using .serialize(). The server should see and urldecode automatically the POST content.

    As a demonstration, see this code:

    HTML

    <form id="category-dynamic" class="dynamic">
       <fieldset id="inner-fieldset">
          <legend id="new-category">
            <label for="category-name">Category Name: </label>
            <input type="text" name="category-name" value="" />
          </legend>
          <ul id="category-fields">
             <li>
               <label>Field #1:</label><br />
               <input type="text" name="fields[]" value="" />
             </li>
             <li>
               <label>Field #2:</label><br />
               <input type="text" name="fields[]" value="" />
             </li>
          </ul>
       </fieldset>
    </form>
    <h3>POST Result</h3>
    <pre></pre>
    

    jQuery

    $(document).ready(function(){
        $('pre').html($('#category-dynamic').serialize());
    
        $.post("http://jfcoder.com/test/processor.php", $('#category-dynamic').serialize(), function(data){
             $('pre').html($('pre').html()+"\n\n"+data);
        });
    });
    

    EDIT

    And the processor.php file contents:

    <?php
    print_r($_POST);
    ?>
    

    EDIT 2

    I think your error is that you’re sending the content in such a way as to make the form data be a text string instead of url-encoded content.

    For instance, you could do this:

    var formSubmit = $(this).serialize() + "&formSubmit=true";
    $.post('ajax.php', formSubmit);
    

    And you’d have the same effect, and the server would be able to expand your POST variables without incident.

    EDIT 3

    See this example:

    Where the code is:

    $(document).ready(function(){
        var serial = $('#category-dynamic').serialize() + "&formSubmit=true";
        $('pre').html(serial);
        $.post("http://jfcoder.com/test/processor.php", serial, function(data){
             $('pre').html($('pre').html()+"\n\n"+data);
        });
    });
    

    Note the addition of the "&formSubmit=true" to the serial data. This outputs from the PHP page:

    POST Result
    
    category-name=&fields%5B%5D=&fields%5B%5D=&formSubmit=true
    
    Array
    (
        [category-name] => 
        [fields] => Array
            (
                [0] => 
                [1] => 
            )
    
        [formSubmit] => true
    )
    

    EDIT 4

    This uses the method you describe. See the difference?

    $(document).ready(function(){
        var serial = $('#category-dynamic').serialize();
        $('pre').html(serial);
        $.post("http://jfcoder.com/test/processor.php", {"formSubmit":"true","serial":serial}, function(data){
             $('pre').html($('pre').html()+"\n\n"+data);
        });
    });
    

    OUTPUT

    POST Result
    
    category-name=&fields%5B%5D=&fields%5B%5D=
    
    Array
    (
        [formSubmit] => true
        [serial] => category-name=&fields%5B%5D=&fields%5B%5D=
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a tough time in figuring out how to use Kevin Murphy's
I'm having some trouble where returning this is somehow returning a different reference/type when
I'm having a heck of a time changing the default location of a form.
I'm learning to create an app for WP7 (Mango), and somehow having this problem.
This seems like a simple problem, but somehow I'm having issues with this code.
I am having problems using the MarkerManager. Somehow Markers added with the MarkerManager do
I'm having problems updating a mysql database. I want to run this script on
I'm having trouble figuring out the best approach for an certain application. I'm not
I'm having problems with binding values from a view to an object. Somehow the
Somehow this doesn't work... var paper = Raphael(test, 500, 500); var testpath = paper.path('M100

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.