Hot answers tagged

15

I've been using Snaptcha http://devot-ee.com/add-ons/snaptcha on my recent sites, I can attest that it works very well, No one enjoys filling out these captchas anyway, and their efficacy is doubtful anyway.


9

It's fairly easy to create an AJAX add to cart button using Store. It's no different from any other AJAX form submission. This used to be in our user guide, but SE is a much better place for "how to" questions so I'll summarize here: The general process is: Create your sidebar cart as a separate template Embed your sidebar cart inside a known div element ...


8

What is the path to load the template in your browser, through EE (like a normal page on the EE site)? Did you try using that path, too? That would be the one I'd expect to work. You'd want to do this anyway if there are any EE tags in the template, to be sure they get parsed. If you try to access the URL of a template file directly with the browser you ...


6

Do you have $conf['hidden_template_indicator'] = '_'; set? This could be causing the issue


6

Are you sure that ajax="yes" is required? I believe freeform autodetects that (for graceful degradation on the client). I haven't checked the FreeForm source but I suspect it could be that you're actually accidentally triggering ajax="no" with that param.


6

When a Freeform form is submitted with AJAX Freeform can provide JSON response containing errors or success, which can be used to display errors. This has worked well for me on previous versions of Freeform. The docs for the latest version of Freeform say that Freeform will detect AJAX automatically and provide a JSON response you can use to display user ...


5

You can use $this->EE->output->send_ajax_response($array); for the same purpose.


5

It's certainly possible without hacking. Just that the EE documentation isn't particularly helpful on how to handle this sort of thing. Basically, you want to write a Module. Then you need to register an "action" in your module's install script: $data = array( 'class' => 'Module_name' , 'method' => 'method_to_call' ); $this->EE->...


5

You can do this if you're willing to programmatically manipulate hidden configuration variables in your config file ;-) I use Focus Labs Master Config style configs, so I have this in my dev config: $env_config['template_debugging'] = 'y'; $env_config['show_profiler'] = 'y'; And, obviously, you can set those to 'n' by-hand to turn off the debugger ...


4

The main problem here is this: keywords="{segment_3}" You probably don't have keywords in the third segment, but an entire encoded query. You're feeding that query as keywords to the URL tag, essentially encoding it twice. If you use the URL tag and you want to work from an existing search action, use query="{segement_3}" to pass all the details from the ...


4

... when the form fields are filled out correctly ExpressionEngine itself throws an "x Field Required" error message("Email Field Required" for the Comment Form ... The comment form code that you've posted includes a from field, not an email field. It seems pretty likely that EE is looking for $_POST['email'] and then bailing when it can't find it. The ...


4

Ok, here's the code: Javascript: $(function(){ $('.ajax_link').on('click', function(e){ // catch the click, and bind that click-event to the variable "e" e.preventDefault(); // stop the event from firing (so user doesn't get forwarded to the actual link) var elem = $(this), link = elem.attr('href'), target = ...


4

It would be difficult to lay out the full code here, but we do something similar, so let me try to point you in the right direction. What you are looking for is normally referred to as "jQuery Autocomplete". A great example can be found here: http://www.ramirezcobos.com/labs/autocomplete-for-jquery-js/ Or use jQuery along with jQuery UI with this: http://...


4

You're currently accessing the template from the wrong URL. EE writes URL's based off the template groups from the root of the site: index.php/template_group/template_name. If you're removing index.php from the URL, just remove it from the snippet below and this should work: $(element).load("index.php/snippets/newswall_news");


4

This works for logging into ExpressionEngine with ajax and showing the appropriate error, you would just modify the code where it checks for the error messages it returns to display to the user. You will need more conditions for the required fields. function displayAjaxMessage(message, response_id) { if(typeof(response_id)==="undefined") response_id = "#...


4

You can avoid the XID validation by making a GET request instead of a POST request. XID validation only occurs when secure_forms is y and the $_POST array is not empty. Or you can generate a valid XID hash by using {XID_HASH} in your template. Maybe something like: <body data-xid="{XID_HASH}"> <script> $.post( 'site/inifinite_scroll_ajax', ...


4

After some guidance from Ahmad Saad below (thanks Ahmad!) I was able to get shipping (and total) calculated after shipping method change. First it will require to change template where shipping form field is located. That part is required due to default shipping value is not loaded when new cart created (in my case). My looks like: <tr> <td>...


4

ExpressionEngine has a protection against Cross-site Request Forgery - CSRF and a documentation available here. You just have to add that line to your form: <input type="hidden" name="csrf_token" value="{csrf_token}"> And send the data in your AJAX request. I had the same problem today and that fixed it for me.


3

In order to make this work with Store 2.0 / EE 2.7 you need to make an extra template with a form so a new XID is generated. After the ajax request to the cart, make a new ajax request to the template with the form. Get the xid from that template and update the xid on your orignal template jquery / ajax: url = 'ajaxform' $.get(url, function(returnData) { ...


3

Something like MadeByHippo's post is a good starting point for querying the DB for the details and return the data that you need via AJAX. With channel data you would need a slightly more complex query but the basis is there.


3

TL;DR: You're binding a callback to the wrong $.ajax option, but that isn't enough to fix this: I would use the Ajax Babble addon and get on with your day, as this problem turns out to be more complex than it looks. While you could do client side validation as Anna suggests, there are all sorts of other error conditions not related to request content that ...


3

Posting the solution for future reference here. There were two parts to this problem. Firstly, it looks like the template partial which was being loaded via ajax had slightly different code than the main template, so for example was using {price} instead of {price_inc_tax}. This caused different price to be displayed for products loaded later on via AJAX. ...


3

I would do the same as Stuart McCoy, but performance wise it's better to use switchee instead of the native advanced conditionals. {exp:switchee variable = "{segment_2}" parse="inward"} {case value="pancakes"} {exp:channel:entries channel="pancakes" dynamic="off"} {title} {sn-pagination} {/exp:channel:entries} {/case} {case value="...


3

Try wrapping each channel entries and each pagination in a conditional. If the pagination layout is identical for each channel entry section then you can throw it in a snippet. It might look something like this: {if segment_2 == "pancakes"} {exp:channel:entries channel="pancakes"} {title} {sn-pagination} {/exp:channel:entries} {if:elseif segment_2 =...


3

Yes, it's possible (assuming you're talking about triggering the ExpressionEngine status message in the control panel, not generically setting flash data from an AJAX request). I had this same question a few days ago - I know for example the CP template manager triggers the success message at the top of the page from an AJAX request, so I went trawling ...


3

I see you're already attempting to grab the new XID from the return data of the Ajax call: // update the XID hash in the form so we don't run afoul of EE's secure forms $("input[name=XID]").val(response.XID); But I fell onto this documentation the other day which I think is new and relating to new EE version handling. Seems like if submitted by Ajax the ...


3

Create a hidden template that is just the logged in username only. Then load it in via jquery ajax .load(); Once login is complete as well. if (event.success) { member_favourites = "5"; //do something $("div#username").load("_username.html"); }


3

I don't think so unless you write a plugin to access the code in the DB. However you could easily create a hidden template IE ( _parsed_data.html). Then AJAX load it in to your to your current template using Jquery AJAX .load(). $("div#parsedData").load("{site_url}/templategroup/_parsed_data.html"); You can also with javascript depending on how you ...


3

I wouldn't recommend this but in cases where you have no choice, e.g. you cannot tweak the code in an app in time or something to that effect, you can opt to conditionally disable secure forms in your config.php or bootstrap. E.g. // Make an exception to make AJAX forms app-compatible // EE 2.7.x introduced mandatory XIDs even for AJAX, but an app won't ...


3

Honestly, I wouldn't even mess with that plugin since that's what it's supposed to do. Just do a simple ajax call and append the data like this. Note the move of #articles to the main template, and paginate_base parameter in the embed template. Main Template <html> <head></head> <body> <section id="articles"> ...


Only top voted, non community-wiki answers of a minimum length are eligible