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

The Archive Base Latest Questions

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

There is a lot of posts about nested Ajax problems, but I can’t figure

  • 0

There is a lot of posts about nested Ajax problems, but I can’t figure out whats wrong with my own.

The problem I see is that the server side script doesn’t receive the form values in the nested Ajax call.

On the client side I get that result2 is null.

The nested Ajax code is encapsulated with // problem.

Can anyone see why the nested Ajax doesn’t receive the form values?

$(document).ready(function(){
    $('form').live('submit', function(){

    // ...

    $.ajax({
        type: "GET",
        url: "/cgi-bin/ajax_confirm.pl",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        //      async: false,

        data: $(this).serialize(),

        error: function(XMLHttpRequest, textStatus, errorThrown) { 
        $('div#create_result').text("responseText: " + XMLHttpRequest.responseText +
                        ", textStatus: " + textStatus +
                        ", errorThrown: " + errorThrown);
        $('div#create_result').addClass("error");
        alert("Error occured in ajax.js confirm code.");

        },

        success: function(result){
        if (result.error) {
            $('div#create_result').text("result.error: " + result.error);
            $('div#create_result').addClass("error");
        } else { // server side script says everything is okay

            var users  = $.parseJSON(result.users);
            var owners = $.parseJSON(result.owners);

            $("#dialog:ui-dialog").dialog("destroy");

            $("#dialog-confirm").dialog({
            resizable: false,
            height: 600,
            modal: true,
            open: function() {
                $(this).children('div.dialog-text').replaceWith("<h3><b>Users</b></h3>" + makeDialogTable(users) + "<h3><b>Owners</b></h3>" + makeDialogTable(owners));
            },

            buttons: {
                Okay: function() {
                $(this).dialog("close");
// problem
                    $.ajax({
                        type: "GET",
                        url: "/cgi-bin/ajax.pl",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",

                        // generate and send parameters to server-side script
                    data: $(this).serialize(),

                    // script call was *not* successful
                    error: function(XMLHttpRequest, textStatus, errorThrown) { 
                        $('div#create_result').text("responseText: " + XMLHttpRequest.responseText + ", textStatus: " + textStatus + ", errorThrown: " + errorThrown);
                        $('div#create_result').addClass("error");
                    },

                    success: function(result2){
                        if (result2.error) { // script returned error
                        $('div#create_result').text("result2.error: " + result2.error);
                        $('div#create_result').addClass("error");
                        } else { // perl script says everything is okay
                        $('div#create_result').text("result2.success: " + result.success + ", result2.id: " + result.id);
                        $('div#create_result').addClass("success");
                        } //else
                    } // success
                    }); // ajax

                } else { // if (is_okay) { ...
                    $('div#create_result').text("Fill out the form to create an activity");
                    $('div#create_result').addClass("error");
                } // else
                }, // Okay

// problem
                Cancel: function() {
                is_okay = 0;
                $(this).dialog("close");
                }
            } // buttons
            }); // dialog
        } //else
        } // success
    }); // ajax

    // ...

Update
Here is the HTML, when shown looks like this

<!DOCTYPE html>
<html dir="ltr">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
    <script src="http://jqueryui.com/ui/jquery.ui.core.js"></script>
        <script src="http://jqueryui.com/ui/jquery.ui.widget.js"></script>
    <script src="http://jqueryui.com/ui/jquery.ui.datepicker.js"></script>

    <script type="text/javascript" src="/ajaxv2.js"></script>

    <script src="http://jqueryui.com/external/jquery.bgiframe-2.1.2.js"></script>
    <script src="http://jqueryui.com/ui/jquery.ui.core.js"></script>
    <script src="http://jqueryui.com/ui/jquery.ui.widget.js"></script>
    <script src="http://jqueryui.com/ui/jquery.ui.mouse.js"></script>
    <script src="http://jqueryui.com/ui/jquery.ui.button.js"></script>
    <script src="http://jqueryui.com/ui/jquery.ui.draggable.js"></script>
    <script src="http://jqueryui.com/ui/jquery.ui.position.js"></script>
    <script src="http://jqueryui.com/ui/jquery.ui.dialog.js"></script>

  </head>
  <body>

    <div class="page-body">

      <div class="create-new">
    <div id="create_result" style="display:none;">
    </div>
    <form id="create_form" name="create_form" action="" method="post">
      <input name="anchor" id="anchor" value="create" type="hidden">

      <label class="new" for="title">Title:</label>
      <input class="new" type="text" name="title" id="title" />

      <label class="new" for="owner">Owner:</label>
      <input class="new" type="text" name="owner" id="owner" /><br class="new"/>

      <label class="new" for="users">Users:</label>
      <input class="new" type="text" name="users" id="users"/>

      <label class="new" for="groups">Groups:</label>
      <input class="new" type="text" name="groups" id="groups" /><br class="new"/>

      <label class="new" for="begin_date">Begin Date:</label>
      <input class="new" type="text" id="from" name="from"/>

      <label class="new" for="end_date">End Date:</label>
      <input class="new" type="text" id="to" name="to"/><br class="new"/>

      <label class="new" for="type">Type:</label>
      <input name="ctype" id="ctype" value="individuel" type="radio" /> Individuel <br/>
      <input name="ctype" id="ctypee" value="course"    type="radio" /> Course <br/>

          <button class="n" type="submit">Create</button>
    </form>
      </div>


      <div id="dialog-confirm" title="Can you confirm?" style="display: none;">
    <div class="dialog-text">
      <p>dialog text goes here</p>
    </div>
      </div>

      <TMPL_INCLUDE NAME="menu.tmpl">

    <table class="alerts" cellspacing="0">
      <tbody>

        <tr class="header">
          <th class="activity-header">ID</th>
          <th class="activity-header">Title</th>
          <th class="activity-header">Owner</th>
          <th class="activity-header">Begin Date</th>
          <th class="activity-header">End Date</th>
          <th class="activity-header">Type</th>
          <th class="activity-header"></th>
        </tr>
      </tbody>
    </table>

    <TMPL_LOOP NAME=ROW>
      <form action="" method="post">
        <input name="anchor" value="<TMPL_VAR ID>" type="hidden">
        <table class="alerts" cellspacing="0">
          <tbody>
        <tr>                                
          <td class="activity-data"><TMPL_VAR ID></td>
          <td class="activity-data"> <input name="title" id="<TMPL_VAR ID>_title"      value="<TMPL_VAR TI>" type="text" /> </td>
          <td class="activity-data"> <input name="owner" id="<TMPL_VAR ID>_owner"      value="<TMPL_VAR OW>" type="text" /> </td>
          <td class="activity-data"> <input name="from"  id="<TMPL_VAR ID>_begin_date" value="<TMPL_VAR BD>" type="text" class="datepick" /> </td>
          <td class="activity-data"> <input name="to"    id="<TMPL_VAR ID>_end_date"   value="<TMPL_VAR ED>" type="text" class="datepick" /> </td>
          <td class="activity-data"> <input name="ctype" value="individuel" type="radio" <TMPL_VAR IN>/> Individuel <br> <input name="ctype" value="course" type="radio" <TMPL_VAR CO>/> Course </td>
          <td class="edit-column"><a href="javascript:showhide('<TMPL_VAR ID>');">Members</a> <input value="Save" type="submit"></td>
        </tr>

        <tr id="<TMPL_VAR ID>" class="edit-row" style="display: none;">
          <td class="activity-data"></td>
          <td  class="activity-data" colspan="5" align="center">
            Users  <input name="users"  id="<TMPL_VAR ID>_users"  size="35" value="<TMPL_VAR US>" type="text" />
            Groups <input name="groups" id="<TMPL_VAR ID>_groups" size="35" value="<TMPL_VAR GR>" type="text" />
          </td>

          <td class="edit-column"> 
          </td>
        </tr>
      </form>
    </TMPL_LOOP>

    </div>

  </body>
</html>
  • 1 1 Answer
  • 3 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-22T12:18:58+00:00Added an answer on May 22, 2026 at 12:18 pm

    on this line in the problem area

    data: $(this).serialize(),
    

    “this” is referring to the dialog itself or possible the ajax

    you’ll want to refer to the specific form you are trying to serialize.

    i would set the value to a variable and log it to test /see what is going on there

    so first figure out what

     $(this) 
    

    is by running

    alert($(this).prop('id')) // or something similar if your using older jQuery use .attr instead of .prop
    

    EDIT
    it doesn’t look like you give the form an id so i’m not 100% sure but i think you can do this

    $('form').live('submit', function(){
    var aform = $(this)
    .....
    

    then in the problam area

     data: $(aform).serialize(),
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that there is a lot of posts about this problem.But can someone
I know there are a lot of posts about this, but I cannot get
I know there are a lot of posts about git workflows, but I couldn't
I've seen there are a lot of posts about XML comparison, but none of
Hey, There's a lot of posts on here about read barcodes but I want
There's already a lot of blog posts out there about being able to hook
I know that there are a lot of posts about this issue, but I've
Although there are a lot of posts about .net config files, I believe that
There are a lot of posts on here about this, I'm using this code
There are a lot of posts about how cool POCO objects are and how

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.