How to set a Ajax URL so that I can use Jquery.post(URL)

How to set a Ajax URL so that I can use Jquery.post(URL)

Hi there, I need quick help for ajax. Let me clarify.

kindly visit this website. You will see there is an option to give a like. I want to create an exact similar thing on webflow, I found the way how it works and I have written the custom code the like amount is increased but when I reload the page it’s back to the previous state. Here is the custom code for that. Look both images
myajax
myajax2

The error says: “portfolio:262 Uncaught ReferenceError: myajax is not defined”
On their website, they declare a URL into myajax variable

But in webflow how can I declare an ajax URL for that so that when I reload the page that page should show the increased value not the previous value?

Here is my site Read-Only: [Webflow - Travisweihermuller
][1]

Hi Mehedi, welcome to the forum.
It looks like you have the right idea except;

  1. You’ve missing your declaration of myajax, which you’ve found. That JSON needs to exist for your URL to be accessible in the POST.
  2. The current URL in that setting points to a wordpress php script. I’m guessing that this will probably go away if you’re replacing the site?

Have a look instead at CountAPI.xyz, which will give you similar counting capabilities.

Or if you want a more complete likes & favorites feature, check out;

1 Like

Thanks, man, You helped me a lot. I have followed the Jetboost one and it works for me. Can you help me with another thing?
https://travisweihermuller.com/portfolio/
Visit the URL again. Look at the commenting feature. Can you tell me how can I create this type of real-time commenting feature in Webflow ?
Thanks again.

Hey Mehedi, I’d recommend you start a new forum post on that, since it’s a totally different topic. You can mark the solution on this one.

I’ll give it some thought and add some ideas there there I get a chance.

1 Like

Hi, I come back again for your help. My client doesn’t want to use CMS. Also, I don’t understand how to work with CountAPI. Can you give me an idea of how to use this on Webflow?

Hey Md, it’s a custom-build project that depends on the features you want and how your site is designed - especially without the CMS.

In general, you need to figure out what an “item” is that can be liked, and how to identify it uniquely, and then you’d use CountAPI to increment a counter and update your page. There are a lot of little moving parts to make this work smoothly.

The most basic implementation requires these APIs;

  • Get item count
  • Increment item count
  • Get all item counts at once

And the code to use those in your page.

A much more advanced implementation requires the ability to store a user’s favorites somewhere ( in browser storage, etc. ) and then mirror that in the API, and allow;

  • Decrement item count

As well if un-favorite is supported.

I’ll direct-message you with my rates, if you need help writing the code for this piece.