Questions tagged [ajax]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
1answer
817 views

Change user password on the front end

I'm building a profile page for members on a site where members can change their password. I'm sending the request with ajax, and can successfully change password if I have the input name "password" ...
2
votes
1answer
649 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 ...
2
votes
1answer
291 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
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 ...
2
votes
1answer
832 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 ...
2
votes
1answer
797 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 ...
2
votes
1answer
1k 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 ...
2
votes
2answers
977 views

500 Internal Server Error in OpenShift install

I'm running into a 500 Internal Server Error when trying to install craft (on openshift). Environment: Platform: OpenShift (nginx-php7 cartridge: https://github.com/pinodex/openshift-cartridge-nginx-...
2
votes
1answer
2k views

if isAjax not working or not detecting ajax request in template

I can't stand this and have to ask for help again.. Still working on my buddy's website. I want to increase a entry's counter (using Entry Count plugin) So for my _entry.html I added an if statement ...
2
votes
1answer
490 views

Updating user profile matrix block with plugin

I've written a plugin to update some user profile fields via ajax. It works great for normal text fields like this 'myWooly' field, ex: <?php namespace Craft; class ProfileUpdateController ...
2
votes
1answer
743 views

How can you use the jQuery pjax plugin with Craft?

There is a jQuery plugin called pjax (https://github.com/defunkt/jquery-pjax/) for downloading page content via ajax. How can you integrate pjax in Craft for downloading entries via ajax? Or are ...
2
votes
1answer
293 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" ...
2
votes
1answer
863 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 ...
2
votes
1answer
333 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
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 ...
2
votes
1answer
91 views

Trying to replace an asset via replaceFile action in entry form

UPDATE: We've resolved this one. Here is the working code: <form method="post" enctype="multipart/form-data" action="" accept-charset="UTF-8"> <input type="hidden" name="entryId" value="{{ ...
2
votes
1answer
1k views

How do I get started with Element API plugin?

I'd like to use the Element API plugin. I've follow the instructions mentioned here: ElementAPI - Can I use javascript/ajax to load json Here is my config/elementapi.php file : <?php namespace ...
2
votes
1answer
538 views

How to create a secondary menu to filter entries?

I have a page where by default it lists all of the entries inside the section 'work'. I'd like to have a secondary menu where I can filter these entries by the field 'projectCategories'. {% ...
2
votes
1answer
399 views

Creating a guest entry, with a Matrix field, using Ajax

I'm trying to submit a guest entry by building a javascript array of objects to mimic a form submission and submit using ajax. I've managed to successfully submit the entry with just a title but when ...
1
vote
3answers
551 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 ...
1
vote
2answers
166 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
1k 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 ...
1
vote
1answer
598 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
1answer
758 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 ...
1
vote
1answer
544 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
2answers
363 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
1k views

Ajax Function on a search form not working in Safari & IE

I made an ajax function so my page wont refresh and my search window wont disappear on form submit. It works fine in all browsers but it keeps refreshing on Safari. Here is my code: {% if not craft....
1
vote
1answer
581 views

Ajax layout sample

I am just learning how to use this CMS and I am able to get basic things done but I have no idea what a ajax layout will look like. I have few pages in old system which fetch info using ajax calls (....
1
vote
1answer
228 views

Delete plugin record via ajax

I have been staring at this SE post on deleting using ajax and it's just not clicking. For example, I have a plugin with a list of users. Each user has a delete icon next to it. template .... <...
1
vote
1answer
854 views

Submit via ajax to Guest Entries plugin

I'm trying to submit entry data via AJAX (using Guest Entries plugin) following what's written in a similar question, however even though I am not sending the data in JSON format, the data does not ...
1
vote
1answer
74 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 ...
1
vote
2answers
281 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
239 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
388 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
1k 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
1answer
66 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
676 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 ...
1
vote
2answers
414 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 ...
1
vote
1answer
995 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
1answer
265 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
1answer
669 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() { ...
1
vote
2answers
139 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 ...
1
vote
1answer
149 views

Tags via AJAX actionTrigger

I pretty much followed this and the answer there really helped me a lot so far. Currently I'm stuck with either a 500 (Internal Server Error) or a 400 (Bad Request) Error. My craft/storage/runtime/...
1
vote
1answer
93 views

Save the form if not complete and come back another time to complete the form

I am using the FormBuilder plugin and I want users to be able to fill in a form. If they abandon the form without completing it or submitting it, I want the form to be saved and when they login and ...
1
vote
1answer
134 views

Formerly - Checking if e-mail already entered

So, I have a form created using formerly and their template. The form works fine, but I am trying to check for duplicate e-mails and just stop a submission when it notices there is one in the system. ...
1
vote
1answer
203 views

Updating index tables' sortable attributes on AJAX

I'm currently writing a plugin enabling users to easily add custom fields to index tables, using the native field layout designer. My current goal is to have any datetime, boolean, string or number ...
1
vote
1answer
27 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
vote
1answer
14 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
1answer
51 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 ...
1
vote
1answer
139 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 ...