Questions tagged [ajax]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
35 views

How to make AJAX request to controller inside module?

Created a new module to receive form values and process API in Craft CMS 4. How to make an AJAX request to access a controller in my module? module name - giftcard controller - GiftCardController ...
Shankar's user avatar
  • 11
1 vote
2 answers
42 views

Update Craft Commerce cart with ajax

Have been trying to get cart updates via ajax. I've looked at this answer: 'https://craftcms.stackexchange.com/questions/17347/update-commerce-cart-using-ajax' My cart seem to update ok but I can't ...
DieselHashtag's user avatar
2 votes
1 answer
143 views

How to use ajax call to retrieve data from craft cms entries to use in php application

I'm building a static webpage with php and Javascript. I have setup all my data in craft cms entries. I want to use ajax to retrieve the data from craft and just display it on my webpage. How do I do ...
Alyx's user avatar
  • 23
1 vote
1 answer
35 views

Ajax increment seq

I think this is the last issue that I have on my dev site before going live. In index.twig I'm outputting the latest articles, some of them are duplicated. In the footer I'm having popper.js tooltip ...
Mensur Hafizović's user avatar
1 vote
1 answer
69 views

Ajax response no longer returns true after updating to craft 4

I have a project that was initially built in Craft 3 and I'm upgrading it to Craft 4. I leverage ajax on one of the pages to save data to a user in the CMS. The following code worked in Craft 3 but no ...
Mike Niland's user avatar
0 votes
1 answer
1k views

fetch post request to plugin shows payload empty when sent as json stringify

When i send body: JSON.stringify(formData) to my plugin controller the payload is empty. When i send just as body: formData then the payload is there but json_decode(Craft::$app->getRequest()->...
joomkit's user avatar
  • 2,004
1 vote
1 answer
98 views

Ajax form submission forbidden error on custom plugin

I am submitting form data to 3rd party api through a custom plugin using fetch. Im setting CSRF token in form like: <input type="hidden" id="subscribe-modal-token" name="{{...
joomkit's user avatar
  • 2,004
0 votes
0 answers
202 views

Ajax entry save error 403

I have a front end form submitting via ajax that was working fine. Im now starting to see 403 exception - something craft is now forbidding. There is no error in the response object. I have the ...
joomkit's user avatar
  • 2,004
1 vote
1 answer
56 views

Craft 3 paginate not working when fetched with a controller

I'm loading a paginate via Craft::$app->getView()->renderTemplate(), this is being executed within a controller. But my pageInfo.nextUrl is now the url of my controller (/actions/controllername/...
Kevon's user avatar
  • 160
1 vote
1 answer
220 views

How to save an entry using AJAX on a frontend Form [ for registered users]

I'm having a follow button on the front end it allows you to save an entry to a specific section (type: channel) and it's all working great, but i need to achieve this with AJAX This is my Form {% if ...
Ra3d K's user avatar
  • 125
1 vote
1 answer
51 views

How to create a follow system "button" for "Event" entries?

First of all, Please excuse my English Q: I have a section called "Events" And and has some entries On the front-end i have a list of card "Events" and each card has a "...
Ra3d K's user avatar
  • 125
1 vote
1 answer
194 views

Loading JavaScript on Template Load

I'm working on a kiosk-type plugin which will cycle through all news entries, beginning upon template (or page) load. It needs to load a JavaScript ajax script for this on page/template load. Would ...
buck1112's user avatar
  • 390
2 votes
1 answer
372 views

Ajax pagination in Craft

I followed this tutorial here on how to paginate without reloading the page: http://craftsnippets.com/articles/dynamic-pagination-for-craft-cms it uses Ajax to load in pagination without re-loading or ...
Wally's user avatar
  • 333
1 vote
1 answer
648 views

Output javascript inside twig variable

I am using the Enupal Stripe Payments plugin to pass line items to Stripe. The line items get passed in an array. I want to use a javascript cart to hold the items in local storage, reformat that and ...
triplethreat23's user avatar
1 vote
3 answers
145 views

Get a list of countries available for shipping with Ajax in Craft Commerce

I need to fetch a list countries available for shipping in Craft Commerce. The problem is that I use decoupled frontend on Nuxt.js and I need fetch it with Ajax call and not with the twig code. I ...
Oleksandr Staniev's user avatar
1 vote
1 answer
153 views

Searching for a way to add products to cart and sending the csrf token with ajax

Searching for a way to add products to cart and sending the csrf token with ajax This is my current code; $('.add-to-cart-form').on('submit', function(e) { e.preventDefault() ...
Bram Beekman's user avatar
1 vote
1 answer
299 views

Craft Commerce 3 Decrease line Item qty by one?

I may be missing something obvious but I'm trying to update a +/- quantity button system for adding products to work on Craft Commerce 3 The desired functionality is that click '+' increases the cart ...
Josh Parylak's user avatar
1 vote
1 answer
85 views

Plugin development - How to access actions?

I have a simple controller in /craft/plugins/craft-dns-notifier/src/conrollers/DnsNotifierController: namespace kokesjan\dnsnotifier\controllers; use craft\web\Controller; class ...
Jan Kokes's user avatar
-1 votes
2 answers
262 views

Multiple jQuery $.ajax() calls from one template

I would like to make multiple Ajax calls from my index.html. One call comes from $(document).ready() function. Second one is invoked from .on("click") event outside the $(document).ready() ...
Jan Kokes's user avatar
1 vote
2 answers
2k views

Load More Entries Button

I am trying to make my entry loop have a load more button, and not sure how to do it. I tried the method from http://craftsnippets.com/articles/infinite-scrolling-and-lazy-loading-with-craft-cms but I ...
Justin Kendall's user avatar
2 votes
1 answer
240 views

Front End Entry Form - File/asset field not saving when ajax submitted

I have a front end entry form which submits and saves fine when not using ajax. But when i do submit via ajax the text fields etc save fine but the file/assets field will not. I have stripped it right ...
mmc501's user avatar
  • 1,779
1 vote
1 answer
76 views

Ajax request returns code instead of result of the query (solved)

I'm trying to answer my own question in this post Basically, I have a bunch of checkboxes in multiple categories and when clicked, I want to use Ajax to filter the results and show them on the same ...
Jake1293's user avatar
  • 149
2 votes
1 answer
1k views

Dynamically populating select input fields using jquery $.load and twig template

EDIT: the below code now works! I have two select inputs, the choice of 1 should populate the second. I have an external twig file (data.twig) (MAKE SURE TO PUT THIS IN YOUR TEMPLATES FOLDER) that ...
Niels's user avatar
  • 75
0 votes
0 answers
67 views

Load Entries after click (AJAX)

I try to load a entry after a button is clicked, currently my code looks like this: This is generating a 404 error. Dunno why? <?php /** * PopUp plugin for Craft CMS 3.x * * test * * @link ...
Michael Reich's user avatar
0 votes
0 answers
218 views

Contact form plugin ajax submit URL not working

I am using contact form plugin for forms in my craft website. For avoiding page redirection, I followed ajax submit for the form, but it is not redirected to controller code. My form is as below:- ...
Rakhi Vijayan's user avatar
2 votes
2 answers
908 views

How could I include another template on a click with ajax?

I am a newbie with ajax and I have to display a template only when clicking on a button. This template is weighing and it will be on all pages, so I want to use ajax. Someone can help me?
gThiffault's user avatar
3 votes
3 answers
1k views

Filter entries with AJAX

How would I sort blog entries displayed using AJAX? What I want to achieve is initially show all posts from a channel (All) but then let my users sort through these posts with a sub navigation using ...
Spheriri's user avatar
  • 132
1 vote
1 answer
240 views

AJAX Update Entry (500 Internal Server Error)

I'm trying to update an entry on the front end with a click and without a form. I'm a bit new with AJAX but would love to simply put a new title for the entry that the button relates to. I'm currently ...
JMKelley's user avatar
  • 1,374
1 vote
0 answers
67 views

Sprout plugin: Send information in AJAX success response

I'm using Sprout for registering to events, I want to be able to send a code in the AJAX response when EVENT_AFTER_SAVE occurs. At the moment, I get {success: true} back, but I want to be able to get {...
Hassan Mahmood's user avatar
1 vote
1 answer
402 views

Ajax Contact Form not sending with Error 400

Hi I have I'm using Craft CMS 3.1.21.1 with the Contact Form plugin version (2.2.4) and Contact Form Honeypot plugin (1.0.2) along with jquery 3.2.1 on the site. Whenever the form is filled out and I ...
T.Newton's user avatar
1 vote
1 answer
484 views

CSRF token is null or empty in craft 2

I'm having an issue with Craft 2.6 and the CSRF token. I enabled Csrf Protection in my general.php file by adding this line $config['*'] array so it looks like: $config['*'] = [ ... '...
WTFranklin's user avatar
1 vote
1 answer
1k views

Ajax Post to Plugin Controller

I have been stuck on trying to make an ajax call to a custom plugin controller in Craft 2 for a few days after trying everything from following the documentation for Craft 2 as well as looking up ...
WTFranklin's user avatar
1 vote
0 answers
285 views

XMLHttpRequest Craft Commerce Cart Update Issues

When using XMLHttpRequest to update cart like the following, I get a 500 error for 'lineItems': {[lineitem]: {'qty': value}} (and also {[lineitem]: {'remove': true}}, any other submission works); var ...
Anders's user avatar
  • 652
1 vote
1 answer
717 views

Ajax post request front-end csrf token

I'm trying to make a simple post request with ajax to a controller in plugin. The problem I'm having is that I always get a 400 Bad request because I don't send a valid CSRF Token. But I can't figure ...
dazz's user avatar
  • 195
1 vote
1 answer
736 views

Filter Entries by Category fields & refresh URL and list with AJAX

I'm finding myself stuck with filtering entries that are related to categories using a category field. I'm looking to build a sub-navigation on a page, where I can select from a select field or from a ...
mateostabio's user avatar
2 votes
1 answer
2k views

CSRF in “Headless” Applications

There are a number of answers here about how to send CSRF tokens along with AJAX requests, but I think my question is a little different. Please excuse the abstractness here: In a headless ...
August Miller's user avatar
1 vote
1 answer
507 views

AJAX CSRF Producing Inconsistent Results

I am using CSRF tokens in a form on CraftCMS. Submissions are successful with a standard configuration. Introducing "fresh" CSRF tokens via AJAX on page load is causing some trouble. This is ...
Chris Chapman's user avatar
1 vote
1 answer
2k views

Craft Commerce 2 Ajax Add to Cart

Trying to ajax add to cart but each submit returns a https://www.website.com/commerce/cart/updateCart 404 (Not Found) I have this in my twig template: {% for book in craft.products().type('books')....
Chattervast's user avatar
1 vote
0 answers
402 views

How can I edit multiple entries via multiple front-end forms using Vue.js?

I found this post. However, writing a plugin in currently not an option, and I'd like to do this with Vue.js since I'm already using it for form validation & other stuff. Also, this involves ...
Andrea DeMers's user avatar
1 vote
1 answer
1k views

Craft 3 Plugin Controller - returnJson() replacement?

In Craft2, when making an ajax request to a plugin controller action, you would use the returnJson() method which is part of the BaseController class - which your plugin controllers extend. This sets ...
JamesNZ's user avatar
  • 937
0 votes
2 answers
274 views

Does Craft save dates in the locale format?

I have a website with multiple locales (English, Dutch, French, German and Spanish). I'm saving dates on a front-end form through Ajax, but it seems that Craft saves the dates in the locales' format, ...
Tom De Smet's user avatar
  • 1,456
1 vote
2 answers
288 views

Sprout forms AJAX submission giving Template not found

I am able to capture submissions from a regular HTML form, however if I replicate the POST with JSON I get the following "Template not found" error. Template not found: sprout-forms/entries/save-...
Lance's user avatar
  • 13
1 vote
1 answer
608 views

Another AJAX CSRF question

I have quite a simple registration form, something like this: <script type="text/javascript"> window.csrfTokenName = "{{ craft.config.get('csrfTokenName') }}"; window....
Tom De Smet's user avatar
  • 1,456
1 vote
1 answer
964 views

CSRF Protection in AJAX post

I'm having some trouble passing CSRF-tokens in my js-File in Craft 3. I'm setting the values in my template like so: <script type="text/javascript"> window.csrfTokenName = "{{ craft.app....
bstnhnsl's user avatar
  • 123
2 votes
1 answer
879 views

Ajax Load more Posts

On my blog i need a load more button on the bottom of each section that simply loads more posts when clicked. Everything i look at people are using other javascript libraries. I just want to use ajax ...
Kevin Love's user avatar
1 vote
1 answer
291 views

How can I call console controllers

I have a controller in the console folder. How can I call this controller via ajax please? I tried to config a route in Routes.php, and then call this route by jquery Get() function. But none of ...
yu xia's user avatar
  • 397
2 votes
1 answer
387 views

Ajax not updating user image

I have ajax submitting my form everything works except the user image. It works without ajax but not sure why it's not working with ajax. My ajax is and form are shown below. <form method="post" ...
Kevin Love's user avatar
1 vote
2 answers
348 views

Ajax User registration sometimes forbidden 403 error [closed]

I am experiencing a very weird issue. I have a simple user registration form: <form method="post" action="" accept-charset="UTF-8" id="addTeacherForm"> {{ csrfInput() }} <input type=...
Branko's user avatar
  • 495
1 vote
0 answers
186 views

Refresh "hidden" template after login with ajax

I am trying to create a seamless user login interaction with a modal form using ajax. Let's say I have a navigation template _navigation.html <div> {% if currentUser %} {{ currentUser }}...
krizajb's user avatar
  • 195
2 votes
1 answer
5k views

Axios post function got 400 bad request

I created a Vue component. And in this component, I use axios to send post request when it's mounted, CSRF token also included, but still got 400 status. Anyone know why?
yu xia's user avatar
  • 397