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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:50:42+00:00 2026-06-08T12:50:42+00:00

Having an issue with the code below. I performed a search on the site

  • 0

Having an issue with the code below. I performed a search on the site and came up with close but no cigar.

I want when the item attached to .callapp is clicked to do the following:

  1. $jQuery.load the content section with the url received from getURL(xapp)
  2. regardless of what the status is, execute the “requesthandler”
  3. if the request happens to be successful, for the “requesthandler” to use onSuccess and execute it

I am not sure how to execute the anonymous function I am passing to the “requesthandler”. I need this anonymous function to execute the “loadURL” function with the params I passed in, which will then spike another chain of events that is irrelevant to this post.

Thanks!

var url = "";
var tab = "";
var app = "base";
var out = "";
$(document).ready(function() {
    $(".callapp").click(function(e) {
        e.preventDefault();
        $('#wxreturn').html("<div id='xtools'></div><div id='xerror'></div><div id='xdapps'></div>");
        hideContent(1, 1);
        $('#xdapps').load( getURL("base"), function(resp, stat, xhr) {
            requesthandler(iStat, iXHR, 0, 0, 0, 0, function() {
                loadURL("tools", "xtools", 1, 1, 1, 1);
            });
        });
        return 0;
    });
});
// piece together a url
function getURL(xapp) {
    // url to return
    var url = null;
    // global tab must not be empty
    if (tab.length) {
        // check if app is defined
        if (!xapp.length) {
            // app is either the global or base
            xapp = app | "base";
        } else {
            // set the global
            if (!(xapp == "tools") && !(xapp == "options")) app = xapp;
        }
        // set the url to return
        url = "/" + tab.toLowerCase() + "/" + xapp.toLowerCase() + "?_=" + Math.random();
    } else {
        // undefined functionality error
        alert("Invalid getURL...Tab Missing");
    }
    // return the url
    return url;
}
// load a url
function loadURL(xapp, target, showApp, showOpt, showTools, clearTools) {
    // defaults
    showApp = showApp | 0;
    showOpt = showOpt | 0;
    showTools = showTools | 0;
    clearTools = clearTools | 0;
    // do only if app and target are defined
    if (!(xapp == undefined) && !(target == undefined)) {
        // set target
        if (!(target.contains("#"))) target = "#" + target;
        // get url string
        var url = getURL(xapp);
        // check if null
        if (!(url == null)) {
            // commence with load   
            $(target).load(url, function(resp, stat, xhr) {
                // call back with the request handler
                requesthandler(stat, xhr, showApp, showOpt, showTools, clearTools);
            });
        }
    } else {
        // undefined functionality error
        alert("Invalid LoadURL...Missing App...Target");
    }
}
// request handler
function requesthandler(stat, xhr, showApp, showOpt, showTools, clearTools, onSuccess) {
    // defaults
    showApp = showApp | 0;
    showOpt = showOpt | 0;
    showTools = showTools | 0;
    clearTools = clearTools | 0;
    onSuccess = onSuccess | null;
    // check for status
    if (stat == "success") {
        // execute
        if (!(onSuccess == null)) {
            // perform function
            (onSuccess());
        }
    } else {
        if (xhr.status == 401) {
            // throw session expired
            sessionTimeOut();
        } else if (xhr.status == 403) {
            // throw authorization failure
            failedAuthorize();
        } else {
            // throw application request failure
            failedAPPRequest(clearTools);
        }
    }
}
  • 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-08T12:50:43+00:00Added an answer on June 8, 2026 at 12:50 pm
    onSuccess = onSuccess | null;
    

    You need to use two | here, not one.

    showApp = showApp || 0;
    showOpt = showOpt || 0;
    showTools = showTools || 0;
    clearTools = clearTools || 0;
    onSuccess = onSuccess || null;
    

    Just to be safe, I’d check if onSuccess was a function (not just that it’s not null) before running it:

    if (typeof onSuccess === 'function') {
        // perform function
        onSuccess();  // the extra "()" aren't needed here
    }
    

    If you do this, the onSuccess || null isn’t needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue in IE9 with onbeforeunload -- when the code below is
I am having an issue on mouse hover effect. My code is below and
I'm trying to learn C++ currently, but I'm having issues with the code below.
I am having an issue with my WinForm application. Below I have my code
I'm having an issue with one of my conditional statements. The code below is
I am having an issue with the below code in one of my views:
I'm having a (probably super simple) issue. The code below is supposed to _POST
I'm having an issue with a TCPListener. I have created this code below and
I am having an issue with the following code below. if ($cursor->count() > 0)
I am having an issue with the below code in one of my views:

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.