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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:23:52+00:00 2026-05-18T00:23:52+00:00

I know this seems like I should have immediately found the one example out

  • 0

I know this seems like I should have immediately found the one example out there that simply explained this concept, and I can’t find the right one. The examples in tutorials out there use flickr as the request url, and I get it up to a point. I’m trying to handle a very complex form with four different buckets of info under one larger bucket of info. I though json would be a good choice. So I found an example that shows me how to serialize the data like this:

    $.fn.serializeObject = function()
{
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        if (o[this.name]) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};

Which is great! Via an alert, I can see the json structure and my form elements. So I thought the rest would be totally simple. And here I am banging my head because I can’t find one simple example of HOW to SEND or REQUEST this serialized data from my processing page which needs to print, organize and calculate the values of what was sent.

So what I did next (and I’m sure it’s wrong, but perhaps this will illustrate how new I am to it and where I need to start in my understanding of it) was to write the serialized data out to a hidden field like so:

$('form').submit(function() {
    var field = '<input type="hidden" name="jsonval" value="' + $.toJSON($('form').serializeObject()) + '">';
   // alert($.toJSON($('form').serializeObject()));

    alert(field);
    document.write(field);
    return true;
});

I’m using the GET method in the form and when it pops the alert it looks fine, then it goes to the next page. Only that hidden var I wrote out isn’t there. The rest of the form values are. I just WANT to see the darn json somehow so I can then use json.parse or whatever I have to use in PHP to decode it.

Here’s the complete code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> 
<html lang="en"> 
<head> 
    <title>Attendees</title> 
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 
    <script type="text/javascript" src="http://jquery-json.googlecode.com/files/jquery.json-1.3.min.js"></script> 
</head> 
<body> 

<form action="receive.php" method="get"> 
  <p><br/> 
    First Name:<input type="text" name="Fname" maxlength="12" size="12"/> <br/> 
    Last Name:<input type="text" name="Lname" maxlength="36" size="12"/> <br/> 
    Preconference:<br/> 
    A:<input type="radio" name="gender" value="A"/><br/> 
    B:<input type="radio" name="gender" value="B"/><br/> 
    What days:<br/> 
    ConfA:
  <input type="checkbox" name="conf[]" value="ConfA"/><br/> 
    ConfB:
  <input type="checkbox" name="conf[]" value="ConfB"/><br/> 
    ConfC:
  <input type="checkbox" name="conf[]" value="ConfC"/>
  </p>
  <p><br/>
    <input name="quote" type="text" value="Enter your meal preference" size="20">
  </p>
  <p><br/> 
    Select a role:<br/> 
    <select name="education">
      <option value="decision">Decision Maker</option>
      <option value="person">Person</option>
      <option value="fcg">Family</option>
    </select>
  </p>
  <p><br/> 
    Select your educational credits:<br/> 
    <select size="3" name="edu">
      <option value="nursing">Nursing</option>
      <option value="welding">Welding</option>
      <option value="case">Case Managers</option>
    </select> 
  </p>
  <hr>
      First Name:<input type="text" name="Fname2" maxlength="12" size="12"/> <br/> 
    Last Name:<input type="text" name="Lname2" maxlength="36" size="12"/> <br/> 
    Preconference:<br/> 
    A:<input type="radio" name="gender" value="A2"/><br/> 
    B:<input type="radio" name="gender" value="B2"/><br/> 
    What days:<br/> 
    ConfA:
  <input type="checkbox" name="conf[]" value="ConfA2"/><br/> 
    ConfB:
  <input type="checkbox" name="conf[]" value="ConfB2"/><br/> 
    ConfC:
  <input type="checkbox" name="conf[]" value="ConfC2"/>
  </p>
  <p><br/>
    <input name="quote2" type="text" value="Enter your meal preference" size="20">
  </p>
  <p><br/> 
    Select a role:<br/> 
    <select name="education2">
      <option value="decision2">Decision Maker</option>
      <option value="person2">Person</option>
      <option value="fcg2">Family</option>
    </select>
  </p>
  <p><br/> 
    Select your educational credits:<br/> 
    <select size="3" name="edu2">
      <option value="nursing2">Nursing</option>
      <option value="weld2">Welding</option>
      <option value="case2">Case Managers</option>
    </select> 
  </p>


<script type="text/javascript"> 

$.fn.serializeObject = function()
{
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        if (o[this.name]) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};

$('form').submit(function() {
    var field = '<input type="hidden" name="jsonval" value="' + $.toJSON($('form').serializeObject()) + '">';
   // alert($.toJSON($('form').serializeObject()));

    alert(field);
    document.write(field);
    return true;
});

</script> 
<p><input type="submit" /></p> 
</form> 
</body> 
</html> 

How do I get it to just communicate in some fashion with the receive.php page? Thanks for fielding such a newbie question. I did search for awhile, but can’t figure out if I need to use a framework, or if there is a nice straightforward way…. There were so many different kinds of examples that were more complex than this problem seemed to call for.

  • 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-18T00:23:53+00:00Added an answer on May 18, 2026 at 12:23 am

    Try putting the hidden input there to begin with

    <input type="hidden" name="jsonval" id="jsonval" value="" /> 
    <!-- also make sure to end your input tags with a "/" -->
    

    And then in your javascript just do…

    var j = $.toJSON($('form').serializeObject());
    
    //You might need this if the quotes are making things annoying
    //j = encodeURIComponent(j);
    
    document.getElementById('jsonval').value = j;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone know this compiler feature? It seems GCC support that. How does it work?
I have a workflow that I want to looks something like this: / Worker
Warning - I am very new to NHibernate. I know this question seems simple
Seems so basic, I can't believe I don't know this! I just need a
I know this isn't strictly a programming question but y'all must have experienced this.
I know that in C++03, technically the std::basic_string template is not required to have
I know this seams a trivial question, but how can I disable the annoying
I know this maybe a basic question but I just can't seem to find
I know this is a subjective question, but why does Hibernate seem to be
The people on this website seem to know everything so I figured I would

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.