Jake235 Posted March 13, 2022 Share Posted March 13, 2022 I want to be able to link xml data. I’m following along a tutorial for Ajax with Mozilla and I know it works. I also know other people have had success with Mercury, but, whenever I try to do it, it fails. Can someone please walk me through that and how to get the exact path to use for the Ajax file? Link to comment
paul2009 Posted March 13, 2022 Share Posted March 13, 2022 We'll need more information if we are to help you. Which tutorial are you following? What are you trying to achieve? About: SQSP User for 17 yrs. Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF Digital, building Squarespace Extensions to supercharge your commerce website. Content: Links in my posts may refer to SF Digital products or may be affiliate links. If my advice helped, you can thank me by clicking one of the feedback emojis below. I love coffee too. Link to comment
Jake235 Posted March 13, 2022 Author Share Posted March 13, 2022 (edited) @paul2009 I’m following this tutorial. I’m volunteering for a non profit and it would make my life a lot easier if I could store sensitive data in an xml file and retrieve it as needed. I know that you are limited with the backend, and, squarespace seems to want to play nice with Ajax, but, whenever I tried all the online solutions, I could not get it to work. Edited March 13, 2022 by Jake235 Link to comment
paul2009 Posted March 13, 2022 Share Posted March 13, 2022 20 minutes ago, Jake235 said: whenever I tried all the online solutions, I could not get it to work Can you be more specific? What JSON data are you trying to query, and why? Also, can you provide a working link to the page where you are trying to do this? About: SQSP User for 17 yrs. Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF Digital, building Squarespace Extensions to supercharge your commerce website. Content: Links in my posts may refer to SF Digital products or may be affiliate links. If my advice helped, you can thank me by clicking one of the feedback emojis below. I love coffee too. Link to comment
Jake235 Posted March 13, 2022 Author Share Posted March 13, 2022 @paul2009 I’m trying to hook into a local .xml file which can be read like data in browsers. Ajax, it’s supposed to natively work with them, but, I believe squarespace has its own flavor of it. Would providing a link be helpful with a free trial? Link to comment
paul2009 Posted March 13, 2022 Share Posted March 13, 2022 (edited) 28 minutes ago, Jake235 said: I believe squarespace has its own flavor of Ajax I think you've picked up mixed messages. If you want to use Ajax to read data then it works exactly the same on Squarespace as it does on any other web builder. I suspect you've been reading about Squarespace's own Ajax Page Loader (Mercury) which they used on Squarespace 7.0 for their Brine family of templates. This is used to load site content more quickly by loading the page body only, not the headers and footers. It isn't related to writing your own Ajax requests and isn't used on newer Squarespace 7.1 sites. Edited March 13, 2022 by paul2009 codeandtonic 1 About: SQSP User for 17 yrs. Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF Digital, building Squarespace Extensions to supercharge your commerce website. Content: Links in my posts may refer to SF Digital products or may be affiliate links. If my advice helped, you can thank me by clicking one of the feedback emojis below. I love coffee too. Link to comment
Jake235 Posted March 14, 2022 Author Share Posted March 14, 2022 (edited) @paul2009, I think you're exactly correct. But, question, since I am using squarespace 7.0, do I need to use it? I am using Squarespace 7.0 and I thought that in order to use AJAX that I had to do something special. I think that the issue is with accessing the squarespace static API on a trial site. I am, however, able to access my Github pages. I have an example of my working code here, and, now that I have a working code, I can play around with things and break things, then, go back to here when I mess up. I believe that I followed this guidance. window.addEventListener('load', loadXMLDoc); window.addEventListener('mercury:load', loadXMLDoc); function loadXMLDoc() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4 if (xmlhttp.status == 200) { document.getElementById("demo").innerHTML = xmlhttp.responseText; } else if (xmlhttp.status == 400) { alert('There was an error 400'); } else { alert(xmlhttp.status); } } }; xmlhttp.open("GET", 'https://#######.github.io/portfolio/Ajax_material/test.txt', true); //This should work xmlhttp.send(); } Edited March 14, 2022 by Jake235 Link to comment
Jake235 Posted April 11, 2022 Author Share Posted April 11, 2022 On 3/13/2022 at 7:00 PM, paul2009 said: I think you've picked up mixed messages. If you want to use Ajax to read data then it works exactly the same on Squarespace as it does on any other web builder. I suspect you've been reading about Squarespace's own Ajax Page Loader (Mercury) which they used on Squarespace 7.0 for their Brine family of templates. This is used to load site content more quickly by loading the page body only, not the headers and footers. It isn't related to writing your own Ajax requests and isn't used on newer Squarespace 7.1 sites. @paul2009, I know it’s been a while. I am learning the AJAX language better. Can squarespace allow AJAX post requests too? Would I have to prevent the form from submitting and do an event listener? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment