Questions tagged [ajax]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
275 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
469 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
142 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
235 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
643 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
341 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
94 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
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
1answer
127 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 ...
1
vote
1answer
827 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 ...
1
vote
1answer
348 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 $...
1
vote
1answer
971 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 ...
1
vote
1answer
78 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/...
1
vote
1answer
169 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....
1
vote
1answer
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-...
1
vote
1answer
401 views

Displaying assets from Craft's cart AJAX response

So, I'm currently building out an eCommerce site for a client. I'm adding products to the cart via AJAX. I'm then sliding out a 'Cart' view panel with the current cart contents, which is being updated ...
1
vote
1answer
472 views

Unknown error occurs on every AJAX call in CP

I was working on a plugin with a hook on onBeforeSaveEntry in my dev environment (which is configured exactly like my live environment). I had a var_dump with an exit in the hook to check output of ...
1
vote
1answer
2k views

Crossdomain ajax request to controller with requireAjaxRequest()

I make request from my localhost(gulp server) to example domain in to VerifyPassword controller. When i make request without headers: {'X-Requested-With': 'XMLHttpRequest'}, It comes as expected 400 ...
1
vote
1answer
966 views

Get entry by slug with EntriesService in ElementAPI

I'm looking to get all entries from one section (say 'videos'), that are related to a specific category. The only reference to the category is the slug that is a parameter in the url: ....dev/videos/...
1
vote
2answers
1k views

Change profile in frontend with ajax

I'm trying to update some checkbox fields through the frontend with ajax. After clicking / change of the checkbox the form needs to update the profile. Template code: <form class="form-...
1
vote
1answer
560 views

Ajax Submittions to Guest Entries

Does anything need to be done to allow for ajax submittions using the GuestEntries plugin? https://github.com/pixelandtonic/GuestEntries I'm following the method used here for Contact form, it ...
1
vote
1answer
507 views

How can you retrieve entries with a specific locale in a plugin?

I have this: $this->requireAjaxRequest(); $segments = craft()->request->getActionSegments(); $lang = $segments[2]; $entryId = $segments[3]; $entry = craft()->entries->getEntryById( ...
1
vote
0answers
44 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
0answers
146 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
0answers
200 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
2answers
180 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
747 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....
1
vote
0answers
137 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 }}...
1
vote
1answer
76 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 ...
1
vote
0answers
620 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 ...
1
vote
0answers
83 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 (...
1
vote
0answers
140 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 ...
1
vote
0answers
97 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 ...
1
vote
0answers
44 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 ...
1
vote
0answers
149 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 "...
1
vote
0answers
2k views

How to get a param from an ajax request in twig?

Ok this has been puzzling me for too long now! I have some code that makes an ajax request: reqAjax: { type: 'get', url: '/mytemplatefolder/myfile.html', data: {town: 'bournemouth'} } ...
1
vote
1answer
1k views

Plugin Controller Ajax Request

I've got a custom controller in my plugin that checks whether or not the request is ajax or not, using craft()->request->isAjaxRequest() In the event that it is, I just want it to return a ...
1
vote
3answers
316 views

How to get user's information when registering or logging in via ajax form

I did search for this but was unable to find the documentation for getting user's data on a return when logging them in from a front-end facing login form (I need to do the same for a registration as ...
0
votes
1answer
850 views

Template for submit via ajax to Guest Entries plugin

I am a bit mystified by how to utilize templates for Guest entries plugin working fine for normal post saving custom fields. When I use ajax to submit I get an XHR 200 response but an HTML response - ...
0
votes
1answer
310 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 ...
0
votes
1answer
421 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 ...
0
votes
1answer
351 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 ...
0
votes
1answer
211 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 ...
0
votes
1answer
163 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 ...
0
votes
1answer
582 views

Can't get correct template for ajax call

Background: I've inherited a site built in craft that has a page called "updates" with a button to load additional entries through ajax. The updates page is an entry in the "page" structure and when ...
0
votes
1answer
104 views

Handling dynamic content

I would like to be able retrieve all entries based on a category selected in a drop down list. From a UX perspective, I would like this to be as seamless as possible and not have to do full page ...
0
votes
1answer
367 views

Craft and AJAX page transitions - how to exclude local hash links from executing AJAX? [closed]

I've got a website in development with new pages loaded via AJAX instead of traditional page loads. Most links on the site will use AJAX to load a new page, however there are some links I need to ...
0
votes
1answer
142 views

How do I prevent a runPendingTask script being included in returned HTML via ajax? [closed]

I have created a route to retrieve some categories via AJAX. When the AJAX call returns the HTML a runPendingTask script is also returned with the HTML. How do I prevent this? /*<![CDATA[*/ (...
0
votes
1answer
148 views

Is it possible to load different “_layouts” with ajax for certain pages?

I've followed this tutorial by Zack Spear. It leaves your website with a header and footer that stay constant while the body of the page is loaded in through AJAX when you change pages. Is it ...
0
votes
0answers
26 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 ...