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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:51:53+00:00 2026-05-27T12:51:53+00:00

I have a situation where I needed to get data from a form submit().

  • 0

I have a situation where I needed to get data from a form submit(). I have given the url in the action and the values to be sent as input elements. The submit is to a REST web service.

I want to retrieve the values from that submit which cannot be done in normal form.submit(), hence I had to use the ajaxForm() call. I think The handler mentioned for success option is called after successful completion of the REST method. I have also given the async:false option as I want to complete the call and then only proceed.

My problem is that The handler is executed after other code i.e. after the call is made the code after the ajax call is executed and then the handler. This is not right if i give async:false right??

This is my code for your reference:

 <form id="form4" action="http://comp1:8080/RestWSGS/jersey/ExcelHtmlTablePlain" style="display:none"
         enctype="multipart/form-data" method="post">
         <input id ="username" name="username" type="hidden" />
         <input id ="wbk" name="wbk" type="hidden" value="new"  /> 
        <input type="submit"  style="display:none" />
</form>

$(function () {
    $('#form4').submit();
    alert(tbLHSString);
}

function showResponse(responseText, statusText, xhr, $form) {

    if (xhr.readyState == 4) {
        tbLHSString = responseText;
    }
    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + '\n\nThe output div should have already been updated with the responseText.');
    executed == true;
}

On the server console I can see that the REST executes perfectly. But I get the variable as undefined and only then the alert from the showResponse happens.

Please help me make this call synchronous!!!
Kavita

  • 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-27T12:51:53+00:00Added an answer on May 27, 2026 at 12:51 pm

    Your AJAX call being synchronous only means that other AJAX calls will have to wait for that one to finish. It does not prevent the JavaScript engine from further execution. I would advise against synchronous calls here, it doesn’t seem to be what you’re after.

    You need to be sure that anything that has to wait until after the AJAX call, is called by the callback, and not immediately after the submit itself.

    The piece of code where you actually initialize the ajaxForm is not included in your question, but I assume that showResponse is being called after successful AJAX request, and that you want alert(tbLHSString); to be called after that. In that case, you would have to move your alert into showResponse.

    If it’s too much code, or for any other reason inconvenient for you to put it in the callback itself, delegate it to a function that is called by the callback.

    $(function () {
        $('#form4').submit();
    }
    
    function onFormSubmitted() {
        alert(tbLHSString);
    }
    
    function showResponse( ... ) {
    
        ...
    
        onFormSubmitted();
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have situation like this: user submits form with action='/pay' in '/pay' I have
I have an application that is scheduled and get some data from a another
i have situation like this: class IData { virtual void get() = 0; virtual
I have situation in which I read a record from a database. And if
I have situation where a user can manipulate a large set of data (presented
We have a situation in our product where for a long time some data
I have recently been in a situation where I needed to perform an operation
I have a situation to parse an XML which is having much data in
I am building a data warehouse. I need to get data from different sources
I have situation, where running a query that filters by an indexed column in

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.