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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:00:02+00:00 2026-05-23T16:00:02+00:00

I have a jquery that has first server function call using post and next

  • 0

I have a jquery that has first server function call using post and next using getJSON(). The jQuery function is given below.

$("#move_up").live("click", function(e) {
            var rqdInstnId = GetRequiredId();
            //alert(rqdInstnId);
            $.post("/Instruction/MoveInstruction", { docId: DocId, instnId: rqdInstnId, action: "MoveUp" });
            //alert("moved");
            //$.ajaxSetup({ cache: false });
            $.getJSON(
            '/Instruction/InstructionTreeView',
            { docId: DocId, instnId: InstnId },
            function(data) {
                //alert(data);
                $.ajaxSetup({ cache: false });
                $('.initialTree').html(data);
                ExpandTree();
                PersistLayout();
                PersistSelection(rqdInstnId);
            });

        });

Here am facing a strange issue. When executing this function, at server side, InstructionTreeView function is first hit(breakpoint) and then only the main function MoveInstruction is hit. But when I alert a text after $.post(“/Instruction/MoveInstruction”, { docId: DocId, instnId: rqdInstnId, action: “MoveUp” });
the functions are hit correctly as expected. Why does this happen? Can any one help with a solution for this?

  • 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-23T16:00:04+00:00Added an answer on May 23, 2026 at 4:00 pm

    Why does this happen?

    Because AJAX is asynchronous. Both requests are triggered almost at identical times and the time when they hit your server is undetermined.

    If you want them to execute sequentially you need to fire the second request in the success callback of the first:

    $('#move_up').live('click', function(e) {
        var rqdInstnId = GetRequiredId();
        $.post(
            '/Instruction/MoveInstruction', 
            { docId: DocId, instnId: rqdInstnId, action: "MoveUp" }, 
            function(result) {
                // The first POST request finished successfully
                // => now trigger the second
                $.getJSON(
                    '/Instruction/InstructionTreeView',
                    { docId: DocId, instnId: InstnId },
                    function(data) {
                        $.ajaxSetup({ cache: false });
                        $('.initialTree').html(data);
                        ExpandTree();
                        PersistLayout();
                        PersistSelection(rqdInstnId);
                    }
                });
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Scenario Using jQuery, I have a page that has a popup overlay containing
I have some content that I am loading using jquery ajax. The content has
I have a jquery menu that has so many entries that it extends further
I have a simple jQuery code that runs on a web page that has
I have a page that has fields dynamically loaded via JQuery. It allows a
I have a simple JavaScript file that has three jQuery $document.ready functions. All three
Ok, I am new to JQuery, I have a modal that has a asp:Literal
I have a JQuery silder that I'm using to set the score on a
We have a form that has fields for first and last name. I was
The problem: I have a jQuery heavy page that has a built in admin

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.