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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:00:30+00:00 2026-06-15T08:00:30+00:00

I have a button named searchReportButton. On this button click, I need to check

  • 0

I have a button named searchReportButton. On this button click, I need to check session value from server using a ajax web method “Error.aspx/CheckSessionExpiry”.This is done in checkSession javascript function. The checkSession is not returning anything now – instead it is handling the required operation based on the result (redirecting to error page).

  1. I need to return the result of ajax web method to the Main Caller. How can we do this return?
  2. Do I need to move the remaining code (from Main Caller) into sucsess callback?

Main Caller

searchReportButton.click(function () {

    checkSession();
    //Remainging Code

});

Helper

function checkSession() {

var win = 101;
$.ajax(
        {
            type: "POST",
            url: "Error.aspx/CheckSessionExpiry",
            data: '{"winNumber": "' + win + '"}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: handleSessionResult

        }
        );
        }

Result Helper

  function handleSessionResult(result) {


    if (result.hasOwnProperty("d")) 
    {
      result = result.d
    }

    if (result == "ACTIVE") 
    {
      window.location.href("Error.aspx");
      return false;
    }

   //alert(result);

}

REFERENCE:

  1. How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?
  2. $.ajax context option
  3. jQuery Ajax Callback does not get Context
  4. jQuery pass more parameters into callback
  • 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-15T08:00:31+00:00Added an answer on June 15, 2026 at 8:00 am

    You cannot. Or, to be more specific, you should not. Ajax request is async which means it does not block other JS operations while it’s being proceeded (imagine 5s browser freeze if the server was responding slowly?).

    Instead you can pass a success callback, which you already do. Then do anything you wanted in there.

    So instead of:

    checkSession();
    //Remainging Code
    

    you should move the remainging code inside the callback:

    function handleSessionResult(result) {
        //... current code
        //Remaining code from the above
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button named Check In . My aim is on click to
I am using an user control which have a button named 'btn_Save'.I need to
I have a main window with a Gtk Button named openDialog. If I click
My $.ajax() is not serializing the button name and value. I have a very
I have a button (named Benjamin): <input type=submit name=btn_submit value=Next &rarr; /> And on
I have a textbox where the user can enter URL and button named Check
I have a radio button group like this : <g:radioGroup name=myGroup values=[1,2,3] value=1 >
I have a button named settings , when I press this button the application
I have a button class named BFToggleButton , derived from UIButton . In my
I have a custom button named ‘rename’. I need the button will always disabled.

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.