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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:34:40+00:00 2026-06-02T17:34:40+00:00

So, near the bottom the jQuery basic pages , it gives this example, NOTICE

  • 0

So, near the bottom the jQuery basic pages, it gives this example, NOTICE how the anonymous function() does not have params. Quote JQuery page says

The anonymous function does exactly one thing: calls myCallBack, with the values of param1 and param2 in the outer scope.

$.get('myhtmlpage.html', function(){
  myCallBack(param1, param2);
});

So, I gave it a try based on this example

My code is like this, similar thing, at line 10, I have an anonymous function(result), but I need to add the param “result” can’t be just function() as suggested by JQuery website, or it won’t work:

<html>
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                var GetResults = function (result) {
                        $("div").html(result);
                    }
                $("button").click(function () {
                    $.get("demo_ajax_load.txt", function (result) {
                        GetResults(result);
                    });
                });
            });
        </script>
    </head>
    <body>
        <div>
            <h2>Let AJAX change this text</h2>
        </div>
        <button>Change Content</button>
    </body>
</html>

My question is, why does JQuery page says it will work with just function() without params? I have to add function(result) to make it work? Am I missing something?

  • 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-02T17:34:41+00:00Added an answer on June 2, 2026 at 5:34 pm

    The key is in the explanation on the link you posted :

    The anonymous function does exactly one thing: calls myCallBack, with the values of param1 and param2 in the outer scope

    This is basically saying that the param1 and param2 variables are defined previously (outer scope) :

    $("button").click(function () {
        var param1 = "something";
        var param2 = "something else";
        $.get('myhtmlpage.html', function(){
           myCallBack(param1, param2); // this uses the previously declared variables
        });
    });
    

    Within JavaScript when you call a function myfunc("some text") for example the actual function could be defined as function myfunc(var1) { or function myfunc() { the first example just formally declares a variable name for the first argument …

    ​function myfunc() {
        alert(arguments[0]);
    }
    
    myfunc("some text");​​​​​​​​​​
    

    arguments that are not formally declared ar available using the arguments array … see this doc on MDN

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

Sidebar

Related Questions

Basically I have a jQuery function that checks if the user is near the
at http://lunatestsite.co.uk my jQuery roundabout near the bottom of the homepage is problematic in
I have a table on near the bottom of the page, which I want
Per this question (see comments near the bottom), I was wondering if anyone knows
I have a page when, if the user is near the bottom of the
Near the bottom of this article ( MSDN ) in a section entitled The
Versioned URL's are mentioned near the bottom of this section with very little explanation:
This issue/quirk/side-effect is driving me crazy. Near the bottom the code, the response code
Near the bottom of this site: http://love-detroit.com/ the is a Listen block. It displays
Ok i have website, and want to change Leave Reply string near the bottom

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.