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

  • Home
  • SEARCH
  • 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 4624750
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:10:24+00:00 2026-05-22T03:10:24+00:00

Im trying to use this jQuery script and this is confusing me: function CallService()

  • 0

Im trying to use this jQuery script and this is confusing me:

function CallService() 
        {
                $.ajax({
                    type        : varType, //GET or POST or PUT or DELETE verb
                    url         : varUrl, // Location of the service
                    data        : varData, //Data sent to server
                    contentType : varContentType, // content type sent to server
                    dataType    : varDataType, //Expected data format from server
                    processdata : varProcessData, //True or False
                    success     : function(msg) {//On Successfull service call
                    ServiceSucceeded(msg);                    
                    },
                    error: ServiceFailed// When Service call fails
                });
        }

The bit im confused about is the sucess object. The jQuery documentation says:

success(data, textStatus, jqXHR)Function, Array

A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event.

But this method signature looks nothing like the:

success     : function(msg) {//On Successfull service call
                        ServiceSucceeded(msg);                    
                        }

Object that we seem to be passing in.

Questions:

1) What does function(msg){ServiceSucceeded(msg)} mean?

2) What is ‘msg’ in this context?

3) How on earth am I meant to know how to structure the method sugnature for sucess?

  • 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-05-22T03:10:25+00:00Added an answer on May 22, 2026 at 3:10 am

    Perfectly reasonable question. 🙂 In JavaScript, you don’t necessarily have to call a function with as many args as it defines, and you don’t have to define as many args as you may get called with. Which can be confusing if you’re used to more constrained environments. 🙂

    Answering specifics:

    1) What does function(msg){ServiceSucceeded(msg)} mean?

    It defines a function (an anonymous one) that accepts one named argument (msg) and calls ServiceSucceded passing in that arg. jQuery will call the function with the three arguments defined by the jQuery documentation for the success function, but this particular success function is only using the first of those (data). More about named functions vs. anonymous functions here.

    2) What is ‘msg’ in this context?

    The first argument to the function. jQuery’s docs call this first argument data, but you can call it whatever you like.

    3) How on earth am I meant to know how to structure the method sugnature for sucess?

    You did the right thing, it’s in the jQuery documentation.

    This thing about function arguments can be confusing, so let’s do some examples:

    function foo(arg) {
        alert(arg);
    }
    

    That’s perfectly clear, I’m defining a function called foo that takes a single named argument, arg. And thus:

    foo("Hi there"); // alerts "Hi there"
    

    But I can also do this:

    foo(); // alerts "undefined"
    

    There, I didn’t give any arguments for foo, and so within foo, arg is undefined.

    I can also do this:

    foo("Hi there", "again"); // alerts "Hi there"
    

    I’m calling foo with two arguments, but foo only makes use of one of them.

    I could define foo to use as many arguments as you pass in:

    function foo() {
        var index;
    
        for (index = 0; index < arguments.length; ++index) {
            alert(arguments[index]);
        }
    }
    

    arguments is an automatic thing all functions have, which is a pseudo-array (it’s not really an Array) of the actual arguments the function was called with. And so:

    foo("Hi there", "again"); // alerts "Hi there", and then alerts "again"
    

    You can even mix named and unnamed arguments:

    function foo(arg) {
        var index;
    
        alert(arg);
        for (index = 1; index < arguments.length; ++index) {
            alert("[" + arguments[index] + "]");
        }
    }
    

    So now

    foo("Hi there", "again"); // alerts "Hi there" and then alerts "[again]"
    

    Note the [] around the second alert, because I started looping with index 1 rather than zero.

    arguments and named args are connected:

    function foo(arg) {
        alert("arg = " + arg);
        alert("arguments[0] = " + arguments[0]);
        arg = "Updated";
        alert("arg = " + arg);
        alert("arguments[0] = " + arguments[0]);
    }
    

    If I do foo("Hi");, that shows these alerts:

    arg = Hi
    arguments[0] = Hi
    arg = Updated
    arguments[0] = Updated

    (It goes the other way, too, if you update arguments[0].)

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

Sidebar

Related Questions

I'm trying to use jQuery.post() function to retrieve some data. But i get no
I am trying to use this jQuery script to make an image caption from
I'm trying to use this tooltip plugin: http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/ . I can't seem to get
I am trying to use the jQuery POST function but it is handling the
Im trying to use this code: <script> jQuery('#MySelectorDiv').fadeTo(500,0.2); </script> To fade out a bunch
I am trying to use JQuery in my ASP.Net 2.0 website in this scenario:
Im trying to use this page slider jquery plugin, you can see the demo
This was interesting. In a select dropdown, trying not to use jQuery (with the
I am trying to find out how to get a jQuery script to work
I'm trying to use blueimp's jQuery file upload script . The files are sent

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.