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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:40:45+00:00 2026-06-12T00:40:45+00:00

See the following line of code: WinJS.xhr({ url: http://someurl.com }).then( function fulfilled(result) { if

  • 0

See the following line of code:

WinJS.xhr({ url: "http://someurl.com" }).then(
          function fulfilled(result)
          {
             if (result.status === 200)
             {
                resDiv.style.backgroundColor = "lightGreen";
                resDiv.innerText = "Success";
             }
          });

As far as I understand, when WinJS.xhr has completed whatever it does then execute the anonymous function ‘fulfilled’ with argument ‘result’

Coming from Java/C++ background, I’m extremely confused with how this code works – how is ‘result’ being passed to this function? Where does it say anything about what ‘result’ is? How can I know what type of object ‘result’ is and how it has a ‘status’ member?

  • 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-12T00:40:46+00:00Added an answer on June 12, 2026 at 12:40 am

    I’m going to break my answer into two parts: The first concerns the actual execution model of Javascript, and the second which concerns the high-level expression as written.

    The Javascript Execution Model

    1. WinJS evaluates to an object.
    2. That object has a prototype which contains an xhr member which WinJS.xhr evaluates to. That member is a function, which we will refer to as A below so that we can keep clear what exactly is going on.
    3. Before we get to that, { url: "http://someurl.com" } returns an object which we will refer to as B.
    4. That object B has a property called url.
    5. A(B) calls a function A with a value B as an argument. It returns an object that we will refer to as C.
    6. That object C has a prototype which contains a member named then. C.then happens to evaluate to a function. That function we will refer to as D.
    7. function fulfilled(result) {...} returns a function that we will refer to as E. It can also be referred to as fulfilled but that fact is not used in this program fragment.
    8. D(E) calls a function D with a value E as an argument. Nothing is done with the return value.

    The high-level view

    There are three functions here; one is a callback (called fulfilled), and the other two may be called “methods”- one xhr of the WinJS global object, and then of a promise object.

    WinJS.xhr({ url: "http://someurl.com" }) creates and returns that promise object. You can convince yourself of this by consulting the documentation.

    The promise object has a method called then which registers what you can think of as an event handler for when the promise is done. The value result – used in that callback registered in then comes from whatever is making that promise done by in fact calling the method done on that promise. You don’t see the code that does that because it’s someplace in the implementation of WinJS.xhr.

    What WinJS.xhr is doing is performing a network request. When that network request is done it will signal the result of that network request (which according to the documentation is an XMLHttpRequest object) through the promise by calling the done() method on that promise. That in-turn calls the callback we registered with the then() method.

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

Sidebar

Related Questions

See the following code of the <?php class DefaultController extends Controller { public function
If you look at the following line of python code: bpy.ops.object.particle_system_add({object:bpy.data.objects[2]}) you see that
I'm getting an error with the following line of code: DCount(Letter Status,Letter Status,[Letter Status]
In the MiniCsvTypeProvider, I see the following line of code: let prop = ProvidedProperty(fieldName,
See following code with resides in fillowing directory mypack.pack1 package mypack.pack1; public class myclass
How can I implement cross browser opacity gradient (not color gradient)? See following code:
in the form action i have the following line\ <form action={URL} method=post target=_self id=xxx
I'm looking through one of my textbooks, and I see the following line of
The following line: string url = HttpContext.Current.Request.Url.AbsolutePath.ToLower(); results in an unauthorizedaccess exception. This is
The following line of code comes from the official dialog/#modal-form example allFields = $(

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.