Jump to content

RKN

Member
  • Posts

    1
  • Joined

  • Last visited

RKN's Achievements

Level 1

Level 1 (1/20)

0

Reputation

  1. I uploaded a simple text file to my Squarespace site (Business Plan subscription, 1 year auto-renewal). I injected javascript into the footer to test code to read the contents of the file (see below). The output in the Dev console (Firefox) is not the contents of the file I expected, but rather - Records: <empty string>. I've used this technique successfully on Wordpress sites. Any idea why this isn't working on Squarespace? UPDATE: Looking deeper, is it possible the responseText is empty because Squarespace doesn't put 'Access-Control-Allow-Origin' in the request's response header? If so, is there another approach I can use to accomplish my goal? <script type="text/javascript"> rawFile = new XMLHttpRequest(); rawFile.open("GET", 'https://lily-pike-4bpy.squarespace.com/s/motd.txt', false); rawFile.onreadystatechange = function () { if(rawFile.readyState === 4) { if(rawFile.status === 200 || rawFile.status == 0) { var allText = rawFile.responseText; console.log('Records:',allText); } } } rawFile.send(null); </script>
×
×
  • 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.