Questions tagged [ajax]
The ajax tag has no usage guidance.
172
questions
2
votes
1
answer
111
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 ...
1
vote
1
answer
30
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 ...
1
vote
1
answer
60
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 ...
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()->...
1
vote
1
answer
93
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="{{...
0
votes
0
answers
192
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 ...
1
vote
1
answer
52
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/...
1
vote
1
answer
187
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 ...
1
vote
1
answer
47
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 "...
1
vote
1
answer
171
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 ...
2
votes
1
answer
345
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 ...
1
vote
1
answer
612
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 ...
1
vote
3
answers
141
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 ...
1
vote
1
answer
149
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()
...
1
vote
1
answer
286
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 ...
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 ...
-1
votes
2
answers
220
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() ...
1
vote
2
answers
1k
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 ...
2
votes
1
answer
233
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 ...
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 ...
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 ...
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 ...
0
votes
0
answers
214
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:-
...
2
votes
2
answers
876
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?
3
votes
3
answers
979
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 ...
1
vote
1
answer
238
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 ...
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 {...
1
vote
1
answer
395
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 ...
1
vote
1
answer
478
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['*'] = [
...
'...
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 ...
1
vote
0
answers
280
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 ...
1
vote
1
answer
699
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 ...
1
vote
1
answer
727
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 ...
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 ...
1
vote
1
answer
492
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 ...
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')....
1
vote
0
answers
391
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 ...
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 ...
0
votes
2
answers
264
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, ...
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-...
1
vote
1
answer
607
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....
1
vote
1
answer
961
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....
2
votes
1
answer
873
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 ...
1
vote
1
answer
283
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 ...
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" ...
1
vote
2
answers
347
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=...
1
vote
0
answers
182
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 }}...
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?
0
votes
1
answer
674
views
Ajax query filter for entries
I'm attempting to set up ajax filtering for entries using jquery. I'm setting variables in my js based on form field values. The js is triggerd when there's a change in a form field and then the ajax ...
2
votes
1
answer
1k
views
Contact Form AJAX not working in Craft 3
This is my first Craft website, and after trying out Craft 2 I decided it would be a good idea to have move my site to Craft 3 for longevity.
I used to the free Contact Form plugin and managed to ...