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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:52:40+00:00 2026-05-19T16:52:40+00:00

I have a set of text files representing a table of data from a

  • 0

I have a set of text files representing a table of data from a third party that I’d like to download using a JavaScript application. They look something like this:

col1 col2 .. coln
vala valb .. valz
valA valB .. valZ
etc..

I’ve been trying to use jQuery to do this. I’ve been able to use $.load, but I don’t want to store the data in the DOM, instead I’d like to parse it out into an object. Whenever I try to use an of the ajaxy methods I’m getting an error I don’t understand. For example:

var myData;
$.ajax({
    type: 'GET',
    url: $(this).attr('source'),
    dataType: 'html',
    success: function(data) {
        myData = data;
    }
});
alert(myData);

Gives me an undefined value for myData. Any suggestions would be appreciated.

  • 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-19T16:52:41+00:00Added an answer on May 19, 2026 at 4:52 pm

    For that code to work the event needs to be syncrounus, in other word, set async: false in the $.ajax-call. The problem comes because ajax is normally async, meaning that when you do the alert, the request might, or might not have finished. Normally though, it won’t cause it takes longer time to fetch a page than to do a function-call. So, by setting async: false, you tell jquery (and the ajax-handler) to wait till the page is finished loaded before you try to alert the data. Another method to achieve the same effect is to do something like this:

    var myData;
    function fin(data) {
        myData = data;
        alert(myData);
    }
    $.ajax({
        type: 'GET',
        url: $(this).attr('source'),
        dataType: 'html',
        success: fin
    });
    

    This approach is probably better than to set async to false, because it won’t make the browser hang while waiting for the page your loading. However, asynchronous programming is not something that is easy to learn, therefore many will find it easier to use async: false.

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

Sidebar

Related Questions

I have set of jquery files.like this : <script src=js/PortalJs/jquery-ui-personalized-1.6rc2.min.js type=text/javascript></script> <script src=js/PortalJs/inettuts.js type=text/javascript></script>
I have a set of data that contains garbled text fields because of encoding
I have a set of large text files that in total contain about 3
I have five text files that need to be loaded into memory. I set
I have a simple application that reads data in small strings from large text
I have a set of data stored in text files, which I have now
Suppose I have some text files (f1.txt, f2.txt, ...) that looks something like @article
I would like to set up an automatic backup of changed/saved text files using
I have a set of text files providing informations that are parsed, analysed and
I have a large set of text files (tab delimited data) I need to

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.