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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:32:09+00:00 2026-06-10T10:32:09+00:00

if I have a function defined earlier, do I need to include parenthesis when

  • 0

if I have a function defined earlier, do I need to include parenthesis when specifying that it should be used for a success callback?

what would be the difference if I did?

as in

function fish_food(){//do something}

$.ajax({
    url: '/',
    success: fish_food
});

or

$.ajax({
    url: '/',
    success: fish_food()
});
  • 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-10T10:32:10+00:00Added an answer on June 10, 2026 at 10:32 am

    fish_food on its own (without parens) acts as a reference to the function object. It allows you to pass the reference to the function around to be invoked at some later date.

    fish_food() (with parens) is a function invocation expression, which causes the function to be executed. The function code is evaluated and run with a value optionally being returned.

    With the AJAX code you supplied (and all async JavaScript involving callbacks) you want to use the fish_food version (without parens). This passes the AJAX code a reference to your success function, to be executed asynchronously once the AJAX code has completed its round trip to the server and back.

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

Sidebar

Related Questions

I have template function compare defined as below. #include<iostream> using namespace std; template<typename T>
In c++ if I have a function that takes a class I have defined
I have a $database object that I need to reference inside another class. Would
I have a function defined in AS3 that's gonna be called from client side
I have Javascript function defined in the main index.html file. One part of this
I have a function defined like this: public static void ShowAbout(Point location, bool stripSystemAssemblies
i have a function defined as follows: void AddHeadCode(std::ofstream &ostream, size_t length){ ostream.write((char*)length, sizeof(length));
I have a function defined inside the script tags of head.(in a JSP) I
Suppose I have a function defined like this: class Foo() { public: void bar(MyClass*
MyActivity implements a CustomListener defined in MyClass.java. I have a function defined in MyClass

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.