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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:16:56+00:00 2026-06-13T22:16:56+00:00

I want to pass a variable into a .load() function, not the URL, but

  • 0

I want to pass a variable into a .load() function, not the URL, but the function that would happen afterwards.

As you can see below, i have an if/else statement. I want to pass a variable into that.
At the moment i have 2 variables which sit outside this $next and $prev, these are outside of the method. I have tried making them global but that doesn’t work. Ideally i want these to be variables as it is used a couple of times.

var $next = $('.nav.next');
var $prev = $('.nav.prev');


method.open = function(settings) {
    var $link_url = settings.url + ' ' + settings.element;

    $($modal_inner).load( $link_url, function(response, status, xhr ) {
        if (status == 'error') {
        var msg = 'Sorry but there was an error: ';
            $( '#error' ).appendTo( '.modal_inner' );
            $( '#error' ).html( msg + xhr.status + " " + xhr.statusText) ;
        }
        else {
            // Get pagination URL's
            var $pag_next = $(this).find('#post').attr('data-pag-next');
            var $pag_prev = $(this).find('#post').attr('data-pag-prev');

            // If URL's add URL and show 
            if( $pag_next != '') {
                $( $next ).attr('href', $pag_next);
            }
            if( $pag_prev != '') {
                $( $prev ).attr('href', $pag_prev);
            }

        }
    });
};
  • 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-13T22:16:57+00:00Added an answer on June 13, 2026 at 10:16 pm

    You can use variables in your parent scope, either local variables from your parent function or arguments from your parent function. For example, if you passed in next and prev into the open method like this, then you could access them in the load handler function.

    method.open = function(settings, next, prev) {
        var $link_url = settings.url + ' ' + settings.element;
    
        $($modal_inner).load( $link_url, function(response, status, xhr ) {
            // you can access next and prev from your parent scope here
            if (status == 'error') {
            var msg = 'Sorry but there was an error: ';
                $( '#error' ).appendTo( '.modal_inner' );
                $( '#error' ).html( msg + xhr.status + " " + xhr.statusText) ;
            }
            else {
                // Get pagination URL's
                var $pag_next = $(this).find('#post').attr('data-pag-next');
                var $pag_prev = $(this).find('#post').attr('data-pag-prev');
    
                // If URL's add URL and show 
                if( $pag_next != '') {
                    $( $next ).attr('href', $pag_next);
                }
                if( $pag_prev != '') {
                    $( $prev ).attr('href', $pag_prev);
                }
    
            }
        });
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi how i can pass variable into this function var _index = $(#sideNewsContent_menu li).index($(this))
I want to pass a variable as text or somehow to make above function
Is that possible to pass variable into regular expression pattern string in jquery (
I have some code within one function that I want to separate into its
I've a great problem. I must pass a variable of a javascript function into
I want to pass the name of a function testMath as a string into
How would I pass a list of values into a function, where the values
I just want to pass my variable data.company_name from callback function: <script> function AjaxInsert()
Hey. I want to pass a variable as an argument into an nth-child selector.
I want to pass a php variable into JavaScript. I have to get from

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.