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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:37:21+00:00 2026-05-26T03:37:21+00:00

I’m trying to get the return value of a utility method I wrote using

  • 0

I’m trying to get the return value of a utility method I wrote using jquery:

function loadFrames(coords, spritesheet) {
    return $.ajax({
        type: "GET",
        url: coords,
        dataType: "xml",
        success: function(xml,code,obj) {return parseFrameData(xml, spritesheet);}
    });
}

So, this method receives two arguments, opens a file (the one pointed to by the “plist” argument) and runs the parseFrameData method.
The latter returns an array of objects.

I would like to use this the following way:

var frames = loadFrames('player.xml', 'spritesheet.png');

but I don’t find the way to say “return the value of the method you called on line starting with “‘success:’ “…

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

    Edit: An answer posted to the question @Tomalak linked to informed me of this cool concept of ‘Promises’, which you might also want to take a look at.

    The point of using $.ajax is generally to make asynchronous requests. Calling it and expecting a value to be returned immediately would be a synchronous request.

    That being said, you can do what you’re asking by using $.ajax in synchronous mode by setting async:false. This may have the affect of locking your browser until the request completes.

    function loadFrames(coords, spritesheet) {
      var myFrames;
    
      $.ajax({
        type: "GET",
        url: coords,
        dataType: "xml",
        async: false,
        success: function(xml,code,obj) {myFrames = parseFrameData(xml, spritesheet);}
      });
      return myFrames;
    }
    
    var frames = loadFrames('player.xml', 'spritesheet.png');
    

    I believe that is will work, but I don’t have a good way to test it. Can anyone else confirm this approach?

    Still it would be much better to do this asynchronously the way @Petah suggests.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.