Questions tagged [ajax]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
0 answers
187 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
0 votes
1 answer
698 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 ...
PhilR's user avatar
  • 418
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 ...
Hayden Tomas's user avatar
1 vote
1 answer
718 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/...
Abdelhafid AABID's user avatar
1 vote
1 answer
858 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 ...
Danielle Frappier's user avatar
1 vote
1 answer
403 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 ...
Steve VW's user avatar
1 vote
1 answer
120 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 ...
brunouno's user avatar
  • 154
1 vote
1 answer
89 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 ...
brunouno's user avatar
  • 154
4 votes
1 answer
3k 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 ...
Eric Snyder's user avatar
1 vote
2 answers
2k 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 ...
Emmanuel's user avatar
0 votes
1 answer
446 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 ...
CreateSean's user avatar
  • 1,973
1 vote
1 answer
69 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. {# ...
analog junkie's user avatar
1 vote
1 answer
903 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 ...
user2190590's user avatar
2 votes
1 answer
367 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({ ...
Mark Notton's user avatar
  • 2,337
2 votes
1 answer
518 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"...
haabe's user avatar
  • 113
2 votes
2 answers
4k 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', ...
Adam McCombs's user avatar
  • 1,695
1 vote
3 answers
2k 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 ...
ToddPadwick's user avatar
1 vote
2 answers
547 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 ...
shorn's user avatar
  • 438
2 votes
1 answer
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 ...
Aiden Bordner's user avatar
1 vote
1 answer
1k 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 ...
Billy Sengsey's user avatar
1 vote
0 answers
842 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 ...
samput's user avatar
  • 51
0 votes
1 answer
318 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 ...
Robbie Post's user avatar
1 vote
1 answer
274 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?
CreateSean's user avatar
  • 1,973
1 vote
2 answers
577 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 ...
Jai Sandhu's user avatar
1 vote
1 answer
782 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() { ...
Alessio Breviglieri's user avatar
1 vote
0 answers
98 views

Include with AJAX

I am fighting since days with this situation: I have a Select field with around 150 item and depending on a selected item a list of icons and names should be shown (around 50). The list of items (...
Jan's user avatar
  • 196
1 vote
2 answers
173 views

How to update front end Craft new row - stuck on JavaScript

I'm building out a front end entry form with a Natrix and everything is coming along fine. However when users create a new row each new row needs to be unique in order to be saved. This is where I'm ...
CreateSean's user avatar
  • 1,973
1 vote
1 answer
173 views

Guest Entries plugin will only submit when logged in - not anonymously (via AJAX)

I am trying to create an entry in a section via AJAX from the front end when not logged in. I am using the 'Guest Entries' plug in for craft to do this. The entries are all the same and consist of ...
TimC's user avatar
  • 21
1 vote
3 answers
732 views

Craft CMS plugin with AJAX gives 404 error

I have created a small craft cms plugin to pull some information from the DB, and everytime I execute the plugin I get a 404. Here is the controller namespace Craft; class ...
MariaZ's user avatar
  • 133
5 votes
2 answers
460 views

Possible to change locale in PHP?

I've got a plugin which is defaulting to English during AJAX calls, but I need it to stick to whatever the current language is. I can send the current locale through via AJAX data, but I'm not sure ...
Lindsey D's user avatar
  • 24k
1 vote
1 answer
1k views

Error 404 When trying to POST to plugin Controller action

Before I dive into my problem, I do want to mention that I did do my due diligence and spent the last two days researching this problem, to no avail, so here it goes: So I'm getting the following ...
stojda's user avatar
  • 163
1 vote
0 answers
172 views

Need help with filtering entries by a custom field using ajax with pagination

I'm fairly new to CraftCMS and am stuck with a little filtering issue. I'm trying to filter a page of entries by a custom field. I'd like to use Ajax so there is no page reload. Here's how I have the ...
Rich Bachman's user avatar
1 vote
0 answers
99 views

SquareBit Charge Plugin: How to retrieve error messages from failed ajax call?

This is a continuation of How could I submit the Charge plugin using Ajax? I'm using the Charge plugin to handle my Stripe payments. I'm having to use ajax to submit the charge form before submitting ...
Jacob Carpenter's user avatar
1 vote
0 answers
54 views

Find category through ajax using ElementCriteriaModel

I'm trying to run a controller action with ajax in a new plugin I'm making. The action needs to return all categories from a group, so nothing impossible here. When I run the actionUrl in the ...
Sander Van Keer's user avatar
2 votes
1 answer
1k views

Element API + JSON data in template

Is there any way to include the JSON response from element API in a template. Let's take the following example: /case-studies.json returns: { data: [ { title: "American ...
sreucherand's user avatar
1 vote
1 answer
482 views

AJAX user registration and JSON returned

I am using business logic plugin to tap into save user event and create some profile field values. public function init(){ parent::init(); craft()->on('users.saveUser', function(Event $...
joomkit's user avatar
  • 2,014
2 votes
1 answer
956 views

AJAX reload include template

I'm working on getting our site set up with Craft Commerce, and I am currently working on a sidebar cart for the site. I've found examples on how to add products to the cart using AJAX and jQuery and ...
Joel's user avatar
  • 127
1 vote
0 answers
174 views

Submit Dropdown with ajax

This works for me, but i would like to solve this with ajax without reloading the page. Choosing the values from the Dropdowns and submit the data per POST Method, so i can return the value with "...
TomS's user avatar
  • 213
2 votes
1 answer
529 views

AJAX Front-end User Registration Form not displaying macro errorList

I have a user registration form on my Front-end which is submitted with Ajax which works fine. The only problem is that if I have any errors, like an already in use username they wont be displayed. ...
Justin Dekkers's user avatar
4 votes
1 answer
1k views

Update cart lineItems through ajax

How do I update the lineItems after I submit the form through ajax? right now it adds the item, but it doesn't show up in the cart, it only shows up when I reload the page. I am adding an item to ...
pinksorceress23's user avatar
1 vote
1 answer
87 views

Access optimizedTitle field within Twig template

I'm trying to access the value set for my optimized title within Sprout SEO. I've had a read through this page: https://sprout.barrelstrengthdesign.com/craft-plugins/seo/docs/advanced-customization/...
rjdvsk's user avatar
  • 105
2 votes
2 answers
1k views

Craft Commerce ajax add to cart, missing information

I add items to my cart using ajax, following the code from this post Update Commerce Cart using Ajax But there are some things missing in the cart object returned on success, they are : The URL of ...
Antonin_artaud's user avatar
2 votes
1 answer
2k views

Complete working example for adding Craft Commerce items to the cart using AJAX and jQuery?

I'm using Craft Commerce and every time I click the Add to Cart button for a product, I'm redirected to the Cart page. This works okay, but I'd like to use AJAX (with jQuery v1.12.4) for this to save ...
Stephen's user avatar
  • 685
0 votes
1 answer
2k views

Update a user image on the front end using Vue.js and Ajax

Following on from this question I am now looking at adding, deleting and updating a user's image on the front end using Vue.js and vue-resource. I have the delete functionality working no problem but ...
Gareth's user avatar
  • 1,605
1 vote
1 answer
222 views

Guest Entries - Two ajax forms for different section entries. Receiving 404 only on second form?

I am using the guestentries plugin to create two different section entries. I have two similar html forms on the same front end page. They both use the jquery validate plugin before submiting via ajax....
Brendan's user avatar
  • 21
10 votes
5 answers
17k views

Updating a user on the front end with Vue.js and Axios

I currently have a working profile update form using purely craft but I would like to now enhance that using Vue and Axios to update via Ajax. I may well submit a couple of questions rather than put ...
Gareth's user avatar
  • 1,605
1 vote
1 answer
2k views

Using pagination with Ajax load.. help need on JS

I am using a template which has a 'LOAD MORE' button beneath a grid of entries (entries 1-10). Click this link loads addition content to the grid via AJAX from another page (which contains entries 11-...
Scott Robinson's user avatar
0 votes
1 answer
178 views

Commerce - Ajax returning obj.success even when failed

I've got a basic jQuery script that I use to update the cart, either through the actions /actions/commerce/cart/updateCart (if product isn't in cart yet) or /actions/commerce/cart/updateLineItem (if ...
taylor's user avatar
  • 1,128
0 votes
0 answers
2k views

CSRF token could not be verified - ajax

I've got a Craft plugin that returns some results based on filter options on the front end. The filter sends an ajax submissions and returns the markup to populate the front end with. I've read the ...
JamesNZ's user avatar
  • 937