Questions tagged [ajax]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
1answer
567 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
272 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
787 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
760 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
902 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
949 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
462 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
735 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
242 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
761 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
308 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
917 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
90 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
799 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
495 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
369 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
533 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
895 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
2answers
74 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
1answer
394 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
646 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
501 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
311 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
554 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
223 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
838 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
2answers
152 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
192 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
297 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
792 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
597 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
393 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
892 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
259 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
663 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
128 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
144 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
91 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
198 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
112 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
1answer
201 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
407 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
125 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 ...
1
vote
2answers
214 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
1answer
595 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 ...