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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:50:46+00:00 2026-06-01T16:50:46+00:00

I am storing some JSON data in a text file to query using jQuery

  • 0

I am storing some JSON data in a text file to query using jQuery Ajax in my page. Currently, my text file contains around 10 facets of data (which could contain an additional 30 facets of data). The JSON data contains a questions and answers to those questions.

In my JavaScript files, I have setup different functions to get specific bits of data.

For example:

function GetAnswer(questionName) {
    var correctAnswer = null;

    jQuery.ajax({
        type: "GET",
        url: "../content/questions.txt",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: "",
        async: false,
        success: function (result) {
            $.each(result, function (i, q) {    
                if (q.questionID == questionName) {
                    correctAnswer = q.correctAnswer;
                    return false;
                }
            });
        },
        error: function () {   },
        complete: function () {   }
    });

    return correctAnswer ;
}

As you can see from my code-snippet, I am looping through my JSON to get the data I need. I have other functions coded in a similar fashion to get the question type, question name etc.

What I am finding is that I am calling these functions one after another to get the data I need. I think the way I am querying my JSON data is not good from a performance point-of-view since I am looping through the whole of my JSON dataset until I find a match.

Is there a better way to query my JSON data?

NOTE: I am having to use a text file to store questions due to restrictions of the technology I am using (SCORM 1.2).

  • 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-01T16:50:47+00:00Added an answer on June 1, 2026 at 4:50 pm

    Looping through your JSON object is relatively quick. What is slow (comparatively) is loading in that text file each time (though it may be cached).

    Either way, I would suggest loading in the JSON either the first time the user initiates a question/answer situation, or just load it in on page load (you can do it asynchronously) and store it for later use.

    Example of the latter:

    jQuery(document).ready(function(){
        var questions = '';
    
        jQuery.ajax({
            type: "GET",
            url: "../content/questions.txt",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: "",
            async: false,
            success: function (result) {
                questions = result;
            },
            error: function () {   },
            complete: function () {   }
        });
    
        function GetAnswer(questionName) {
            var correctAnswer = null;
            $.each(questions, function (i, q) {    
                if (q.questionID == questionName) {
                    correctAnswer = q.correctAnswer;
                    return false;
                }
            });
    
            return correctAnswer ;
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code to get some json formatted data: $.ajax({ type: GET,
I'm using ajax to retrieve some data from the backend. I get the result
I'm trying to parse some JSON data from the Google AJAX Search API. I
i have some json data, and i want to convert it into plain text,
I'm trying to POST some JSON data using Adobe Flex but having some problems.
I'm storing some additional per-user information using the AUTH_PROFILE_MODULE . We can access the
I am looking at storing some JMX data from JVMs on many servers for
My application is storing some data in SQL Table called Transactions. Users are able
Imagine a web-application storing some data-resource with some id which stores three attachment (e.g.
I am looking for some examples on storing some data into Google cloud storage

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.