Questions tagged [ajax]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
25 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:- ...
1
vote
2answers
42 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?
1
vote
2answers
88 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
1answer
79 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
0answers
34 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 {...
0
votes
1answer
113 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
1answer
138 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
1answer
229 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
0answers
102 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 ...
0
votes
1answer
179 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
1answer
225 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 ...
1
vote
1answer
520 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
1answer
152 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
1answer
636 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
0answers
133 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
1answer
516 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
2answers
91 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
2answers
124 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
1answer
343 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
1answer
617 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
1answer
506 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
1answer
100 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
1answer
201 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
2answers
203 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
0answers
127 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
1answer
2k 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
1answer
332 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
1answer
665 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 ...
1
vote
1answer
453 views

Load new entry(s) in the same page with ajax as a popup

First time I'm going to use Ajax with Craft CMS therefore I'm still confused how it works. What I need is this, when I click on a specified link in the front, I need the CMS to load some entry/...
1
vote
1answer
544 views

When to hide show more button

I am use a load more button in place of pagination. I just using jquery and ajax using this post as a starting point. The problem I'm having is how to hide the button when there is no more posts to ...
1
vote
1answer
314 views

Filter entries by ajax to controller

Short story: I need your help sending value from dropdown selection as data to controller so my div updates with the filtered entries based on the selection. Long story and code: I have a listing of ...
1
vote
1answer
85 views

Ajax - How to create a Category through actionTrigger

I'm trying to create a jQuery/Ajax script to import data from a Wordpress API service and want to import the WP categories and tags into my database. I've managed to import the tags using an Ajax call ...
1
vote
1answer
68 views

Ajax - Create tag with custom ID programatically

I'm trying to create an jQuery/Ajax script to import data from a Wordpress API service and want to import the WP tags into my database. Everything works as expected when I loop through the data and ...
3
votes
1answer
2k views

Basic ajax - how to?

I am new to Craft. I have done some ajax in the distant past. I have searched this forum and see lots of issues with ajax but it seems that there are a lot of different approaches. Craft docs have ...
1
vote
2answers
677 views

How can I create a zip file containing all assets from an entry gallery?

I'm trying to create a download button which will allow the user to quickly download all assets in an entries image gallery. I've started by adding each image url into an array stored in a data attr ...
0
votes
1answer
318 views

Ajax pagination not loading last entries if not equal to pagination number

I've got ajax working on a page but if the number of articles is not exactly 3 (this is the pagination limit) then the remaining 1 or 2 entries do not get loaded. I'm not sure why or how to resolve ...
1
vote
1answer
64 views

load include not until its needed

I have created an infinite loop by crossreferencing two includes to each other. On one page. My aim is to load pop up layers on a page (teachers and instruments) and have links to each other. {# ...
1
vote
1answer
554 views

How to set up a social media feed with vue and axios

What I need is a social media stream with posts with the Hashtag mnbasel form Instagram, Facebook and Twitter. I couldn’t find any good tutorial. Hopefully someone can tell me what I miss or lead me ...
2
votes
1answer
253 views

Hidden files are no longer accessible with AJAX in Craft 3

I'm not sure if this is a bug, a security feature, or something to do with Twig 2; but since Craft 3 (RC3) I'm no longer able to access hidden twig files via ajax. This works fine: $.ajax({ ...
2
votes
1answer
293 views

Solspace Freeform plugin: AJAX without jQuery – how?

I am trying to post data using AJAX. The docs describes a method here. But that is mainly for jQuery. I have also looked at this url, which also uses jQuery. But from what I understand, the "action"...
2
votes
2answers
2k views

Craft 3 - ajax request to plugin

This is a pretty simple test before I implement some larger functionality. Eventually this will be just a glorified upload form via ajax. Part 1 - Ajax post $.ajax({ type: 'POST', ...
1
vote
3answers
1k views

Contact Form plugin - using Ajax, CSRF 400 bad request

I am using the Contact Form plugin with AJAX. I have used the JS AJAX script supplied in the plugin but i get a 'Bad request: CSRF token could not be verified' error. I have seen many other posts on ...
1
vote
2answers
363 views

Saving new entry via Ajax then immediately showing it

I’ve created a very simple comments system whereby comments are set us a channel, with each (comment )entry related to a main entry from another section. Works fine. I’ve set up editing and deleting ...
2
votes
1answer
1k views

JQuery $.ajax “:success” form logic with Plugin Controller?

I'm working on a simple plugin to facilitate front-end, anonymous lead generation forms submitted to Salesforce via cURL to it's Web-to-Lead servlet. The logic and data transfer are working (debug ...
1
vote
1answer
795 views

Simple AJAX search form

So I've been following the docs on how to create a search form in Craft and it works fine. But instead of having a results.twig page I would like to have just one index page and get all the results ...
1
vote
0answers
511 views

How to access logged in CSRF token?

I’m currently using react as a font end SPA with craft cms as the backend. I’m trying to create user accounts where a user use can sign up and favourite content on the site, using the Like for craft ...
0
votes
1answer
181 views

Dynamic entries limit via dropdown

On a entries (listing) page I'm using pagination and a fixed limit of entries set. I want visitors to be able to select (dropdown) the number of entries that should be listed (limit). I'm not a Java ...
1
vote
1answer
255 views

Ajax Submit with AM Forms - How To

Is it possible to submit to an AM Forms form via Ajax? I cannot find anything in the docs? Is there a tutorial somewhere?
1
vote
2answers
292 views

Update Commerce Cart using Fetch

Hi this is a variation of the question asked here on updating the cart using ajax, instead I'm attempting to use the Fetch API. As a test the form submits properly when submitting in the usual way ...
1
vote
1answer
644 views

Ajax call to action 404

I've a trigger on my frontend that requires an action. I've started from the businessLogic template but I'm getting a 404 and can't find why. My function public function actionExampleAjax() { ...