3rddigital Posted August 2, 2019 Share 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 }) Link to comment
paul2009 Posted August 2, 2019 Share 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 About: Squarespace Circle Leader since 2017. I value honesty, transparency, diversity and great design ♥.Work: Squarespace Developer and founder of SF Digital, building the features Squarespace didn't include™. Content: Links in my posts may refer to SF Digital products or may be affiliate links. Catch up on all the release notes and announcements 2023 [for Circle members only]. There's a public version here too!If I helped, you can thank me by clicking one of the emojis below. If you prefer, you can buy me a coffee.Improve your online store with our extensions. Link to comment
3rddigital Posted August 2, 2019 Author Share 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 ? Link to comment
3rddigital Posted August 2, 2019 Author Share Posted August 2, 2019 Ok let me do it.Thanks for the helps Link to comment
3rddigital Posted August 6, 2019 Author Share Posted August 6, 2019 It's works.Thank you so much Link to comment
3rddigital Posted August 6, 2019 Author Share Posted August 6, 2019 It's works.Thank you so much Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.