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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:55:35+00:00 2026-06-09T23:55:35+00:00

Here is my code var jsonpath; function loginFromDef() { var a = grantAccess($(‘#login :input’).serialize());

  • 0

Here is my code

var jsonpath;

function loginFromDef() {

    var a = grantAccess($('#login :input').serialize());
    if (a.Msg) {
        $('#msg').html(a.Msg).attr('class', 'error');
    }
    else if (a.done) {
        var returnUrl = getQueryString('ReturnURL');
        if (returnUrl)
            window.location = returnUrl;
        else
            window.location = 'Home.aspx';
    }


    return false;
}

function grantAccess(dataToPost) {

    $.ajax({
        type: "POST",
        url: jsonpath + 'Json.ashx?method=GrantAccess',
        async: false,
        data: dataToPost,
        success: function (data) {
            return data;
        }
    });
}

function getQueryString(name) {
    var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
    return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}

var jsonPath is being defined in Default.aspx page where from I m calling function loginFromDef() on onclick event of submit button.

I am getting error TypeError: a is undefined
Don’t worry about my .ashx handler. It is working fine. I’d test it.

I think var a in function loginFromDef is not being initialized. Because may be jQuery is making asynchronous call. Even I have set async:false in options.

Whats wrong with me..?? Please suggest a solution to 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-06-09T23:55:36+00:00Added an answer on June 9, 2026 at 11:55 pm

    You don’t have any return statement in grantAccess. The return statement inside the callback does not have any effect (since it is called by $.ajax internally).

    The Ajax call is synchronous but you are not returning any data from grantAccess.

    You could do:

    return $.ajax({
        type: "POST",
        url: jsonpath + 'Json.ashx?method=GrantAccess',
        async: false,
        data: dataToPost,
    }).responseText;
    

    Maybe you have to use $.parseJSON before you return that value.

    $.ajax returns a jqXHR object, which you can find more information for in the documentation.

    However, I strongly suggest to not use synchronous Ajax calls and I don’t see any reason why you would need one here. Synchronous request can potentially block the browser (including its UI) until the response was received, making the browser unresponsive which leads to a bad use experience.

    Change your code so that you can use callbacks to handle the response. For example:

    function loginFromDef() {
    
        grantAccess($('#login :input').serialize()).done(function(a) {
            if (a.Msg) {
                $('#msg').html(a.Msg).attr('class', 'error');
            }
            else if (a.done) {
                var returnUrl = getQueryString('ReturnURL');
                if (returnUrl)
                    window.location = returnUrl;
                else
                    window.location = 'Home.aspx';
            }
        });
    
        return false;
    }
    

    where grantAccess simply returns the jqXHR object returned by $.ajax:

    function grantAccess(dataToPost) {
        return $.ajax({
            type: "POST",
            url: jsonpath + 'Json.ashx?method=GrantAccess',
            data: dataToPost
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code: var showNo = 1; window.setInterval(function() { console.log(showNo); if(showNo === 1)
Here is some code: var class = function(elem,div){ this.elem= elem; this.div = div; this.init
I have this code here: var Person = (function() { var name; var PersonConstructor
Here is my chunk of code: var update_shipping_methods = function(methods) { $(methods).each( function(i) {
Here is my code: var var_ids = new Array(); var i = 0; jQuery(select).each(function()
First off, here's my code: var variable1 = 10; function f1 (){ alert(variable1); }
First of all, here's my code: var users = {}; //User Connect io.sockets.on('connection', function
I have the following code: var myModule = (function($) { // Insert code here
In my code here: var manTimer:Timer = new Timer(1700,5); manTimer.addEventListener(TimerEvent.TIMER, moveMan); function moveMan(e:TimerEvent):void {
Here is my code: var $container = jQuery('#hentry-wrapper'); $container.imagesLoaded( function(){ $container.masonry({ itemSelector : '.hentry',

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.