Hot answers tagged

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

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

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

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

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

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 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

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

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"> ...


2

YYYYYYEEEEEEEEESSSSSSSS!!!! Thank F for that. I have got this working. Peter's answer was the right way to go. It was in the docs all along! For those that may run into a similar situation, I fixed this by adding the recommend ajaxPrefilter that is mentioned in the docs - with a little tweak to define the form. An updated JS Fiddle: http://jsfiddle.net/...


2

Yes, you need to get a new XID each time via Ajax and update your form hidden value, so next time the form is submitted it uses the new XID. Depends what your Ajax is returning of course and where it's submitting to, but in the past on return from the Ajax submission, I've fired another function to just do an Ajax request, then do the replacements. For ...


2

You can use send_ajax_response() which will return JSON and works well for response to ajax requests. For your example you'd do public function mealDates() { $array = array( 'foo' => 'bar', ); return $ee()->output->send_ajax_response($array); }


2

I usually do all of my AJAX form submissions with the jquery ajax form plugin. This allows you to customize the experience for your users here is the link to the plugin its very simple to implement. http://malsup.com/jquery/form/ Hope this helps!


2

Do you have Process form data in Secure Mode? set to "Yes" in your Security and Session Preferences? That could be your issue. If you do, then EE will give a "The action you have requested is invalid." error message instead of using your template, and you'll never be able to get your POST data. I tried your code and it works as long as Process form data in ...


2

Use stash to cache the results (refresh every x minutes, overwrite=no) for fast access. Chain your ajax request, and use channel:entries limit and offset parameters (e.g. after the first 50 return, hand them to map handler and call same/next ajax with new offset) Option 2 will do several requests in a row, which might not be what you want. edit: example ...


2

...and also a checkbox that will show whether the user has completed that resource You can't store the member choices in the channel entries information. Well, technically you could, but it would have to store every members details so not optimal and not recommended. I'm assuming there could be a crossover - so 2 courses could share the same resource. So ...


2

I checked and I can see the XID param being sent to the jquery.ajax by looking in chrome network panel, i can see the query string it builds. So we are good there. It sounds like you are sending the XID in GET instead of POST data. CSRF tokens must be present in the POST data if POST data is received by ExpressionEngine. 2.7.3: POST: XID 2.8+: POST: ...


2

Move the click handler to the wrapping div. $('#cal_container').on('click', '#prev, #next', function(event) { event.preventDefault(); /* Act on the event */ }); Has to do with the original event handler in your code not being passed to the dynamically inserted html. There's a good explanation found here: http://toddmotto.com/attaching-event-...


2

The documentation code is an example, and therefore may need tweaking for fit your particular goals. File fields are different from "regular" fields, since no text or data is present inside the field when submitting, as you would have it with text fields for example. The above code simply serializes the form's text data to be sent through ajax, and ...


2

Two approaches come to mind, the first is to load everything (all results) and only show X at a time (JavaScript) based on your own custom pagination or lazy loading effect. But that means you'd still be sending to the browser all the raw html initially, so might have performance issues. How channel:entries works with the limit parameter in ExpressionEngine ...


2

EE doesn't have a native API interface to communicate with, but I've been having quite a good time with Webservice API plugin from Reinos, and with it you can turn a EE install into a REST/XMLRPC/SOAP server. They've also done the hard work of connecting with many third-party add-ons. Check out the docs here.


1

Try this, and instead of hiding output2 after the dom has loaded add style="display:none;" to #output2 in the html. $(document).ready(function() { var options = { target: '#output2', // target element(s) to be updated with server response beforeSubmit: showRequest, // pre-submit callback success: showResponse ...


1

as answer for your last update change your code to : $(document).ready(function() { $("#shipping_method").change(function() { var url = $(this.form).attr('action'); var p_data = $(this.form).serialize(); $.post(url, p_data , function(data) { var new_shipping = $('<div />').append(data).find('#oso').html(); ...


1

I tested this and it works just fine. Be sure to include the title input with valid data. If you're still having trouble, be sure to check the console log data object. If you dig around you'll probably find the pertinent error. <!DOCTYPE html> <html> <head> ... </head> <body> {exp:channel:form channel="your_channel" json="yes"} ...


1

You could probably load in http://ee-zoo.com/docs/visitor/examples/forgot_password.html dynamically with Ajax into another template with relative ease. Perhaps you could adjust http://ee-zoo.com/docs/visitor/examples/login_ajax.html and call it in at an appropriate time. If that's not quite right for you, could you clarify what you're after with the ajax ...


1

Try: $helpful.find(".ajax-response").load(link, function(response, status, xhr) { $helpful.find(".voters").hide(); $helpful.find(".ajax-response").html(response.message); }); Ajax submissions return a JSON array as a response. You need the correct key (in this case .message) in this array to display only text. Another method for general-purpose ...


1

Create a div. Throw your login box inside. Style and position it how you want. Set it to 'display: none'. Create an event listener, which when triggered, sets the display property to block or anything but none. Create a listener, which will set it to display none. $( '.context' ).on( 'click', '.my_hidden_Div', function( event ) { event.preventDefault()...


1

First of all, check if URL to the root directory of your site URL to your 'themes' folder is setup correct in EE > Admin > General Configuration If you will not found any error inside this settings, you need to open chrome inspector and check what exactly happens. On tab Network you will able see the ajax request (url & headers) + results. ...


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