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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:55:50+00:00 2026-05-13T00:55:50+00:00

I am loading a simple txt file from the same server as the current

  • 0

I am loading a simple txt file from the same server as the current web page using jQuery – this file will always include a plain number with no formatting – e.g. 123456

$(document).ready(function(){    

  var test;
  $.getJSON('myfile.txt', function(data) {
    test = data;
    showAlert(); // this call will display actual value
  });

  function showAlert() {
    alert(test);
  }

});

At the moment, the code pulls the file in and then shows the content in an alert box but what I want to do is read through the response character by character and create an HTML string which I can then insert in to the page – each character would be converted to an image tag.

For example if the response was 123 I want to create a string holding the following HTML:

<img src="1.png" />
<img src="2.png" />
<img src="3.png" />

And then I will insert that string into a div on my page.

Can anybody suggest how to go about looping through the response to create the img tags?

Thanks

  • 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-13T00:55:50+00:00Added an answer on May 13, 2026 at 12:55 am

    I love jQuery.map for stuff like this. Just map (ie convert) each number to a snippet of html:

    var images = jQuery.map((1234567 + '').split(''), function(n) {
      return '<img src="' + n + '.png" />'
    })
    
    images[0]; // <img src="1.png" />
    images[1]; // <img src="2.png" />
    images[2]; // <img src="3.png" />
    // etc...
    

    which you can then join('') and jam into the DOM in one swift punch:

    $('#sometarget').append(images.join(''))
    

    And bob’s your uncle.

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

Sidebar

Related Questions

After loading a PHP template (using jQuery's load function), this simple script won't make
I'm loading a simple page using: $.get('../admin/login.php', function(data) { $('#box-contents').html(data); }); Now, on this
I have a simple question: if I use URLConnection.setUseCaches(true) when loading something from web,
In my application i have one web view .I will loading a simple html
I'm loading a rather simple XML file from a URL. I wanted to show
How to display simple progress loading image on file upload in PHP? without the
I want jQuery to periodically load a text file located on my server into
I just start using jqgrid, but when I try the most simple example (loading
I need to glob ./../path/to/files/**/*.txt but instead of receiving matches like this: ./../path/to/files/subdir/file.txt I
I have simple CCAnimation loading from playlist, and when i test it on emulator

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.