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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:53:50+00:00 2026-05-21T22:53:50+00:00

Has been a long night am struggling here. I have a form which is

  • 0

Has been a long night am struggling here.

I have a form which is loaded into a div via ajax.

The button on the form makes another ajax call serialising the data, but when I call serialise it does not get the form data.

I cant understand why?

THE FORM:

<form id="orderData">
        <table border="1" cellpadding="2" cellspacing="0" bordercolor="#d9d1cb" bgcolor="#666666" class="contact"  style="margin-top:10px;"s="s">
           <tr>
              <td colspan="2" bgcolor="#666666"><input type="text" name="name" id="name" style="width:250px;  border:0;" class="required contact"/></td>
              <td width="116" class="contact">Name:</td>
           </tr>
           <tr>
              <td colspan="2" bgcolor="#666666"><input type="text" name="surname" id="surname" style="width:250px;  border:0;" class="required contact"/></td>
              <td class="contact"><label for="name">Surname:</label></td>
           </tr>
           <tr>
              <td colspan="2" bgcolor="#666666"><input type="text" name="email" id="email" style="width:250px;  border:0;" class="required email contact"/></td>
              <td class="contact"><label for="email">Email:</label></td>
           </tr>
           <tr>
              <td colspan="2" bgcolor="#666666"><input type="text" name="telephone"  style="width:250px;  border:0;" id="telephone" class="contact"/></td>
              <td class="contact"><label for="telephone">Telephone:</label></td>
           </tr>
           <tr>
              <td colspan="2" bgcolor="#666666"><input name="mobile" type="text" id="mobile" style="width:250px;  border:0;" class="contact" /></td>
              <td class="contact">Mobile:</td>
           </tr>

           <tr>
              <td colspan="2" bgcolor="#666666"><textarea name="address" id="address" style="width:250px; height:50px; border:0; font-family:Arial, Helvetica, sans-serif;" cols="50" rows="2" class="required contact"></textarea></td>
              <td valign="top" class="contact"><label for="address">Address:</label></td>
           </tr>
           <tr>
              <td colspan="2" bgcolor="#666666"><input type="text" name="city" id="city" style="width:250px;  border:0;" size="32" class="required contact"/></td>
              <td class="contact"><label for="city">City:</label></td>
           </tr>
           <tr>
              <td colspan="2" bgcolor="#666666"><input type="text" name="postcode" style="width:250px;  border:0;" id="postcode" size="32" class="required contact"/></td>
              <td class="contact"><label for="postcode">Postcode:</label></td>
           </tr>
           <tr>
             <td colspan="2" align="right" valign="top" bgcolor="#666666"><select name="hearabout" id="hearabout" class="contact">
               <option value="Google">Google</option>
               <option value="Other search engine">Other Search Engine</option>
               <option value="ES Magazine">ES Magazine</option>
               <option value="Telegraph">Telegraph</option>
               <option value="Guardian Magazine">Guardian Magazine</option>
               <option value="Passesd by">Passed By</option>
               <option value="From a friend">From a friend</option>
               <option value="Other">Other</option>
             </select></td>
             <td valign="top" class="contact">How did you hear about us?</td>
           </tr>

           <tr>
              <td width="47" class="contact"><input name="send_email" type="hidden" value="send" /><input name="brochure" type="checkbox" id="brochure" value="1" /></td>
              <td width="197" class="contact"><div align="left"><strong>Request Brochure:</strong></div></td>
              <td class="contact"><input name="ordersamples" type="submit" class="button_contact" id="ordersamples" value="Order Samples" /></td>
           </tr>
        </table>
        </form>

the ajax call attached to the submit button:

$("body").delegate("#ordersamples", "click", function(e){
        e.preventDefault();
        var formData = $('#orderData').serializeObject();
            console.log(formData);
        if (swatchArray.length <=0){
            //alert('no samples');
            jQuery.facebox('<table width="100%" border="0" cellspacing="2" cellpadding="2"><tr><td>No samples selected.<br>To select a fabric sample simply click once on it and your selection will appear in the samples panel at the right of the page.<br>When you have made your selection (maximum 7 samples), fill out the form and click on ‘Order Samples’</td></tr><tr><td></td></tr></table>');
            //Prevent the submit event and remain on the screen

            return false;
        } else {
            //alert('has samples');
            var myUrl = 'sendswatch-data2.php';
            var formData = $('#orderData').serializeObject();
            console.log(formData);
            $.ajax({
                url: myUrl,
                data: {'swatchid[]':swatchArray, 'formdata':$('#orderData').serializeObject()},
                type: "POST",
                error: function(xhr, statusText, errorThrown){
                    // Work out what the error was and display the appropriate message
                },
                success: function(myData){
                    $('#tabsampleorder').html(myData);
                    $('.tabber').hide();
                    $('#tabsampleorder').show();
                }
            });
        }
    });

and here is the function I use to serialise the data:

$.fn.serializeObject = function(){
        var o = {};
        var a = this.serializeArray();
        $.each(a, function() {
            if (o[this.name] !== undefined) {
                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;
    };
  • 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-21T22:53:51+00:00Added an answer on May 21, 2026 at 10:53 pm

    i did say it was a late night!!!

    stupid/tired me did not put in a name for the form added that and its working!!!!

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

Sidebar

Related Questions

It has been a long question, so here is the summary first, I have
It has been a long time since I used java and I have run
It has been long time since we have been validating our forms using JavaScript.
It has been a long time since I have developed content in Facebook, so
It has been a long time since I have written XSL, I have this
Perl has long been my choice scripting language but I've run into a horrible
This has been bothering me for a long time now: Lets say i have
I have a C++ code base that has been working for a long time.
It has been a long while since I have really worked with J2EE so
It has been way to long since I have been involved in VB so

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.