I'm trying to create ajax script where the user clicks a button
e.g.
Product Type Alpha
Product Type Beta
It then sends that response via ajax to a new page and remembers what the user selected but now asks more questions.
I'm trying to do the first stage, but having no luck;
- jQuery(document).ready( function($) {
- jQuery('.sectors .sector_btn').click(function() {
- var myVar = jQuery(this).attr('name');
- jQuery.ajax({
- type: 'POST',
- url: location.origin + '/filter-page/?product_type=' + myVar,
- dataType: 'json',
- success: function( myVar ) {
- console.log(myVar);
- },
- error: function(xhr, ajaxOptions, thrownError){
- alert('Error, but product type is: ' + myVar);
- }
- });
- });
- });
It just errors and shows me the right name attribute, but doesn't send the data to the new page (and populates or remembers for "stage 2").
Any ideas where I've gone wrong....?