We help IT Professionals succeed at work.
Get Started

form values are not coming even though serialize() is used in the case of jquery modal window.

chaitu chaitu
Last Modified: 2012-08-14
form values are not coming to server side in the case of jquery modal window.

i used $('#users').serialize() to serialize text box values which are under table id ='users'.

my doubt is this table is not under form thats why values are not coming.how to solve this problem??

<style type="text/css">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
<meta charset="utf-8">
        body { font-size: 62.5%; }
        label, input { display:block; }
        input.text { margin-bottom:12px; width:95%; padding: .4em; }
        fieldset { padding:0; border:0; margin-top:25px; }
        h1 { font-size: 1.2em; margin: .6em 0; }
        div#users-contain { width: 350px; margin: 20px 0; }
        div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
        div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
        .ui-dialog .ui-state-error { padding: .3em; }
        .validateTips { border: 1px solid transparent; padding: 0.3em; }
    $(function() {
        // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
        $( "#dialog:ui-dialog" ).dialog( "destroy" );
        $( "#dialog-form" ).dialog({
            autoOpen: false,
            height: 550,
            width: 350,
            modal: true,
            buttons: {
                "Create an account": function() {
                    var bValid = true;
                  $( this ).dialog( "close" );
                Cancel: function() {
                    $( this ).dialog( "close" );
          /*  close: function() {
                allFields.val( "" ).removeClass( "ui-state-error" );

function callAJAX()
						url: "url",
						dataType: "json",
						data: $('#users').serialize(),
						contentType: "application/json; charset=utf-8",
					    success: function(data){ 
							error: function(e, xhr){ 

        $( "#create-user" )
            .click(function() {
                $( "#dialog-form" ).dialog( "open" );
					$( "#fname" ).val($( "#fname1" ).val());
					$( "#lname" ).val($( "#lname1" ).val());
					$( "#email" ).val($( "#email1" ).val());
					$( "#zipcode" ).val($( "#zipcode1" ).val());

<div class="demo">

<div id="dialog-form" title="Create new user">
    <p class="validateTips">All form fields are required.</p>

    <form id='frm'>
        <label for="name">First Name</label>
        <input type="text" name="name" id="fname"  class="text ui-widget-content ui-corner-all" />
        <label for="email">Email</label>
        <input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
        <label for="zipcode">Zip Code</label>
        <input type="text" name="zipcode" id="zipcode" value="" class="text ui-widget-content ui-corner-all" />
        <label for="lname">Last Name</label>
        <input type="text" name="lname" id="lname" value="" class="text ui-widget-content ui-corner-all" />

<div id="users-contain" class="ui-widget">
    <h1>Existing Users:</h1>
    <table id="users" class="ui-widget ui-widget-content">
            <tr class="ui-widget-header ">
                <td>First Name</td><td>   <input type="text" name="fname1" id="fname1"  /></td>
                <td>Last Name</td><td>   <input type="text" name="lname1" id="lname1"  /></td>
          <tr class="ui-widget-header ">
                <td>Zip Code</td><td>   <input type="text" name="zipcode1" id="zipcode1"  /></td>
                <td>Email</td><td>   <input type="text" name="email1" id="email1"   /></td>
            <tr class="ui-widget-header ">
                <td>SSN</td><td>   <input type="text" name="ssn" id="ssn"  /></td>
                <td>DOB</td><td>   <input type="text" name="dob" id="dob"  /></td>
          <tr class="ui-widget-header ">
                <td>Address</td><td><input type="text" name="addr" id="addr"  /></td>
                <td>City</td><td>   <input type="text" name="city" id="city"  /></td>
<button id="create-user">Create new user</button>


Open in new window

Watch Question
Top Expert 2004
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE