Jump to content

Reading contents of a text file using JavaScript

Recommended Posts

Site URL: https://www.norwoodbaptistchurchri.org

I have uploaded a text file (LastService.txt) and I am now trying to read the contents of it using JavaScript. 

Here is a snippet of code.  I get an error because JavaScript doesn't find the page.  I commented everything else out so I believe I don't have the right path to the text file.

<script type="text/javascript">
function readTextFile() {
    var rawFile = new XMLHttpRequest();
    var filepath = 'https://www.norwoodbaptistchurchri.org/s/LastService.txt';
    rawFile.open('GET', filepath, true);

Link to comment
  • 1 month later...
  • Replies 2
  • Views 797
  • Created
  • Last Reply

Top Posters In This Topic

On 8/12/2021 at 7:15 AM, KenMarrocco said:

Site URL: https://www.norwoodbaptistchurchri.org

I have uploaded a text file (LastService.txt) and I am now trying to read the contents of it using JavaScript. 

Here is a snippet of code.  I get an error because JavaScript doesn't find the page.  I commented everything else out so I believe I don't have the right path to the text file.

<script type="text/javascript">
function readTextFile() {
    var rawFile = new XMLHttpRequest();
    var filepath = 'https://www.norwoodbaptistchurchri.org/s/LastService.txt';
    rawFile.open('GET', filepath, true);

Have you upload the file? I can not find it either

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

Me too! No find file!

Was/is your site in trial mode? If so uploaded files aren't available until the site is paid for. But before you pay for a site you'll want to make sure you have the right URL.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.