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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:29:59+00:00 2026-06-03T07:29:59+00:00

I am an absolute newbie to jquery. So this might be a very basic

  • 0

I am an absolute newbie to jquery. So this might be a very basic question, please bear with me.

I have defined a jQuery function, which creates a 2-d array.

    <script type="text/javascript">
        $(document).ready(function() {
            $.ajax({
                url: '/testdata.txt',
                dataType: 'text',
                success: function(data) {
                    var datatable = [];
                            // Populate datatable[]. This is a 2-d array.
                            $('#myTestDiv').text(datatable[2][0]);
                        },
                        error: function(){
                            alert('error!');
                        }
                    })
                });
    </script>

<body>
    <table>
        <thead>
        </thead>
    </table>
</body>

Now, I want to print the 2-d array, “datatable”, in the HTML table, preferably with JSTL. But it appears that the “datatable” variable is not accessible outside . I know that the table is being populated correctly, the $('#myTestDiv').text(datatable[2][0]); is printing expected output.

How to achieve this?

Thanks a lot.

  • 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-03T07:30:01+00:00Added an answer on June 3, 2026 at 7:30 am

    Remove var from in front of the variable declaration. This will result in the variable being placed on the global window object, making it accessible from all over. Be careful with this type of practice though, as polluting your global context is frowned upon.

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

Sidebar

Related Questions

I'm an absolute newbie to Varnish & caching in general, so this question might
Absolute beginner question: I have a template file index.html that looks like this: ...
absolute newbie in this space so please adjust :-) this has to work on
absolute newbie here: I have table with columns: resource, resource_type_field, value. I have this
Absolute newbie question, any help is highly appreciated :) I am using curvycorners (
Disclaimer: absolute novice in Scala :( I have the following defined: def tryAndReport(body: Unit)
Absolute noob question. I have a form <form> <input type=text id=cars name=cars/> </form> When
I'm an absolute newbie to Moose and so far I have read Moose and
I'm an absolute newbie in this field and I'm kind of frightened of heading
In which absolute position of an object I clicked? I tested with: object.onclick=function(e){ var

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.