Jump to content

jQuery click event not working sometime

Recommended Posts


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.


$(document).on('click', 'target', function () { 
// ajax code here 

Link to comment
  • Replies 5
  • Created
  • Last Reply

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.


    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:


I hope that helps.


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


This topic is now archived and is closed to further replies.

This topic is now closed to further replies.
  • 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.