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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:47:55+00:00 2026-06-16T21:47:55+00:00

I am on creating a simple class with 2 methods: Init (‘/path/to/xmlfile’) test (stuff)

  • 0

I am on creating a simple class with 2 methods:

  • Init(‘/path/to/xmlfile’)
  • test(stuff)

The main problem is that test method depends on the XML file loaded to work.
So, when I do something like this:

f.init('/sources/model.xml');
f.test(it);

it fails because test uses a structure that is made when the XML file is loaded.

Since I am using jQuery to load XML file, with get method, I can do some stuff
this way:

f.init('/sources/model.xml',
    function() {
       if (this.test(it) ) {
            alert('OK, it works!');
        }else {
            alert('Wrong!');
       }
   });

and put my callback inside the success callback of get jQuery method….
BUT, is possible do something like that I put above?

I would appreciate any help.

Note:
I tried with a variable "loaded" inside test function, and a setInterval function to check if the XML file is loaded, but it didn’t work for me.

  • 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-16T21:47:57+00:00Added an answer on June 16, 2026 at 9:47 pm

    You should use callbacks to prevent blocking but if you really want to have the init function block until it receives a response, you could opt to use the $.ajax method instead of $.get

    $.ajax supports an async option, which if set to false will block script execution until the server responds

    Basic Usage:

    $.ajax({
        url: "/path/to/file"
        type: "GET",
        async: false,
        success: function(data) {
            // do something
        }
    });
    

    Documentation,
    http://api.jquery.com/jQuery.ajax/

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

Sidebar

Related Questions

I created a simple class to hide the details of creating a toolbar in
I'm currently creating my first android app and I've a simple class 'Player' I
I'm creating simple example on JSF. It's small Login application. My problem is duplicate
I have a class that generates a text file. It is very simple class
I have created a simple repository class that is returning a list of Projects:
When creating a class in Python, I can simply make a def __len__(self): method
I'm creating a (theoretically) simple hasMany relationship within a domain class. I have two
I am currently creating a project that needs to have a simple async task
I have a test application, with a class TestSeq and a method Go(), which
I am creating simple app on Silverlight 4. In folder of View I have

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.