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

  • Home
  • SEARCH
  • 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 6811263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:18:21+00:00 2026-05-26T20:18:21+00:00

I have a page with an ajax filled autocomplete field, if an extra addition

  • 0

I have a page with an ajax filled autocomplete field, if an extra addition to the autocomplete is needed, based upon the user selctind add new on the (‘mainForm’) I am popping up a modal form (‘subForm’) in which to enter the new data, process on the server using classic asp via an ajax post I would then like to pass the resulting data (two fields returned after a database insert, locId and locName) back to orginal form.

Original form

<form method="post" action="default.asp" name="mainForm" id="mainForm">

 .... rest of form ....

  <label for="locName">Location (autocomplete): </label>
  <input type="text" name="locName" id="locName" value="locName"/>
  <label for="locId">Location Id: </label>
  <input type="text" name="locId" id="locId" value="locId"/>
  <input type="submit" name="sub" id="sub"  value="sub"/>
</form>

Modal Form

<form name="subForm" id="subForm" action="default.asp">
  <label for="nme">Name</label><input type="text" name="nme" id="nme" />
  <label for="pcd">Postcode</label><input type="text" name="pcd" id="pcd" />
  <input type="submit" name="sub2" id="sub2"  value="sub2"/>
</form>

The modal form is then processed on the server after an ajax submit. The form is submitted to a database and creates two values (id,name) – I’d like to to pass these values back to the original form into

Jquery so far

$(document).ready(function() {
  var $form = $('#subForm');     
  $form.submit( function() {
    $.ajax({ 
      beforeSend:function(response){$("#locName").val("loading...");},
      cache:false,
      data: $(this).serialize(), 
      type: $(this).attr('method'), 
      url: $(this).attr('action'),

// this is the bit I need help with  

      success:function(response){
        $("#locName").val(response); // populate original form
        $("#locId").val(response); // populate original form
      },
// ---------------------------------------------
      error:function(){alert("error")},
      complete:function(){alert("done");}
    });           
  return false;  
});
});

Thanks in advance

Steve

  • 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-26T20:18:22+00:00Added an answer on May 26, 2026 at 8:18 pm

    Assuming that ‘response’ is a JSON formatted string returned by your server (e.g. "{locName:'Groenland', locId:'212'}"):

    success:function(response){
        //You need to first parse JSON data:
        var data = jQuery.parseJSON(response);
    
        //Then fill the original form
        $("#locName").val(data.locName); // populate original form
        $("#locId").val(data.locId); // populate original form
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page full of links that each AJAX in an article based
I have a page with a form with data filled by ajax post; on
At the minute I have a page with an AJAX script that searches a
I have a page that I am using an Ajax Accordion and when I
I have a page that loads content through AJAX. Among this content are some
I have an HTML page that uses AJAX to retrieve messages from a server.
I have a page that has several ajax submission forms. Each form has a
I have a page that loads other pages via Ajax (think frames, except without
I have a page with multiple DevExpress gridviews which are late-loaded via ajax. The
I have a page, with ajax URL on it, ofcourse this page is applying

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.