3rddigital Posted August 2, 2019 Posted August 2, 2019 Hi I have created one page and i am sending data to my other site through third party api url on jquery click event , but when i am submitting form my api is not calling. It's sometime work and sometime not work. Can you please tell me is anything blocking squarespace ? I have put my code inside Page Settings -> Advanced. E.x $(document).on('click', 'target', function () { // ajax code here })
paul2009 Posted August 2, 2019 Posted August 2, 2019 This is because of Ajax - not the Ajax that you want to use in your code, but the Ajax that is built into the newer Squarespace templates. There are currently two issues: Where the code is located. Code inserted into the Page Settings panel will not load when Ajax is enabled, unless the page is opened directly or refreshed. Code should be added to the Footer Injection or to a Code Block. The code itself. $(document).on will only fire on a load of the full page, not an Ajax load. You need to trigger a function using Squarespace's onInitialize or mercury:load instead. For a longer explanation of Ajax (that may help others who read this) see the guide I wrote here: https://sf.digital/squarespace-solutions/why-doesnt-my-code-work-until-i-refresh-the-page I hope that helps. -Paul Squarespace Expert & Professional Developer Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links. Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.
3rddigital Posted August 2, 2019 Author Posted August 2, 2019 Thanks for replay. So do you mean i have to write code inside Settings->Advance->code-injection ->footer ? But I have also tried that but same issue. First time will not work if i am doing hard refresh then its work. Can you please suggest me what i do ?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.