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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:35:22+00:00 2026-06-10T20:35:22+00:00

How do I use jQuery.post with a complex dynamically created form? Here is my

  • 0

How do I use jQuery.post with a complex dynamically created form?

Here is my code:

<html>
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="/media/css/screen.css" />
<script>
var id = 0;

function removeField(fieldId) {
    $('#field_'+fieldId).hide();
}

function addField(fieldType) {
    var html = '<tr id="field_'+id+'"><td><input type="button" value="X" onclick="removeField('+id+')"/></td><td><input type="hidden" name="field_'+id+'_type" value="char"><input name="field_'+id+'_name" type="text" value="" /></td><td>'+fieldType+'</td><td><input type="checkbox"  name="field_'+id+'_unique" /></td>';
    switch (fieldType) {
        case 'char':
            html += '<td> <strong>Max length:</strong> <input name="field_'+id+'_max_length" type="text" value=""/></td>';
            break;
        case 'foreignkey':
            html += '<td> <strong>Related model:</strong> <input name="field_'+id+'_related_model" type="text" value=""/></td>';
            break;
    }
    html += '</tr>';
    $('#fields').append(html);
    id += 1;
    $('#fields').show();
}
</script>
</head>
<body>

<form action="/create_model/" method="post">

<strong>Model name:</strong> <input type="text" name="name" /><br/>
<table id="fields"><th style="width:10px;"></th><th style="width:100px;">Name</th><th style="width:50px;">Type</th><th style="width:25px;">Unique</th><th></th></tr></table>
<strong>Add field:</strong> <input type="button" value="Char" onclick="addField('char');" />
<input type="button" value="ForeignKey" onclick="addField('foreignkey');"/><br/>
<input type="submit" value="Create Model" />
</form>

</body>
</html>
  • 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-06-10T20:35:24+00:00Added an answer on June 10, 2026 at 8:35 pm

    If your form is correctly formatted, you can simply use jQuery’s serialize() function together with the post() function. It will build you a query string of your parameters in the form.

    var content = $("#formElement").serialize();
    
    $.post('server.php',{'data':content},function(response){
      // request success callback
    });
    

    serialize

    The .serialize() method creates a text string in standard URL-encoded notation. It operates on a jQuery object representing a set of form elements.

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

Sidebar

Related Questions

I use jquery code like below $('form#new-post').ajaxForm({ success:function(html){ $('#post-list').prepend(html); } }); It show the
I have a standard form in mvc4 operation. I use jQuery.post to perform postback
I'm attempting to use jQuery's $.ajax() function to post form variables to an MVC
my first post here. I'm not new to JQuery, but I find complex coding
I use jquery post function to go to server and bring the link to
basically my aim is to use JQuery to post back an x & y
quick question, is it secure to use the jQuery.post function in jQuery to pass
Assume we use jQuery.ajax() to POST data with two parameters, game_id and player_id .
When i use jquery's $.post ajax function, page freezes for 2-3 seconds and then
I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method

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.