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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:05:48+00:00 2026-05-27T17:05:48+00:00

I m using Ajax call to check whether a user has logged in or

  • 0

I m using Ajax call to check whether a user has logged in or not. If not, show login dialog; else I want OnClientClick to return true so that the form will submit. I m thinking about using a global variable and check it until Ajax gives it a value… I am not sure whether it is the right way? Thanks!

(the server side code already works)

in .ascx:

<asp:Button ID="buttonSubmit" Text="Submit" OnClientClick="return buttonSubmitOnclick()" OnClick="buttonSubmit_Click" runat="server"/>

in .js:

function buttonSubmitOnclick() {
  showLogin();
  //What to do here??? how to get the result after the ajax call?  
}


//========== Ajax ==============

function showLogin() {
  var xmlhttp;

  if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
  }
  else {// code for IE6, IE5
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange = function () {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        if (xmlhttp.responseText == "false") {
            $find('modalPopupLogin').show();  //Show Login Dialog
        };//else is it possible to return a true to buttonSubmitOnclick?
    }
  }
  xmlhttp.open("GET", "AjaxService.aspx?t=auth", true);  
  xmlhttp.send();
}
  • 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-27T17:05:48+00:00Added an answer on May 27, 2026 at 5:05 pm

    when the condition satisfy, you can submit the form manually on response of ajax call using document.forms['myForm'].submit().
    Make the button as normal button(not submit button) and remove the return before the function call in the button element and then do as below:

    function buttonSubmitOnclick() {
      showLogin();
      }
    
    
    //========== Ajax ==============
    
    function showLogin() {
      var xmlhttp;
    
      if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
      }
      else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
            if (xmlhttp.responseText === "false") {
                $find('modalPopupLogin').show(); // display the pop up
            }else{
            document.forms['myForm'].submit() // else submit the form,'myForm' is form id'
                }
        }
      }
      xmlhttp.open("GET", "AjaxService.aspx?t=auth", true);  
      xmlhttp.send();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method I want to call using AJAX in rails but I
I'm trying to validate a form using an AJAX call to check available inventory.
I'm using jQuery AJAX call to dynamically display search results when a user types
I'm using jQuery to make an Ajax call using an Http Post in ASP.NET
I am trying to perform a nested AJAX call using the following code. The
I am loading feed-items into a ul using this jQuery .ajax() call, which I
I am trying to pass a dataString to to an ajax call using JQuery.
I am using an Ajax.ActionLink to call an Action in a Controller, nothing special
I'm using $.post() to call a servlet using Ajax and then using the resulting
I am using jQuery to make an AJAX call to a ruby method 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.