Error in Opencart purchase button

Asked

Viewed 134 times

1

By clicking the buy button it does nothing, by the console appears the following error

Error: Syntax error, unrecognized Expression: #product input[type='text'], #product input[type='Hidden'], #product input[type='radio']:SELECTED=TRUE, #product input[type='checkbox']:checked, #product select, #product textarea

$('#button-cart').on('click', function() {
$.ajax({
    url: 'index.php?route=checkout/cart/add',
    type: 'post',
    data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:SELECTED=TRUE, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
    dataType: 'json',
    beforeSend: function() {
        $('#button-cart').button('loading');
    },
    complete: function() {
        $('#button-cart').button('reset');
    },

site:www.personaleplantas.com.br

1 answer

0

Error this one:

 data:$('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:SELECTED=TRUE, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),

This is not an array, it’s not value, it’s nothing, you need to extract the values from those fields before, for example:

data:{
    $('#product input[type=\'text\']').val(),
    $('#product input[type=\'hidden\']').val(),
    $('#product input[type=\'radio\']:selected').val(),
    $('#product input[type=\'checkbox\']:checked').val(),
    $('#product select option:selected').val(),
    $('#product textarea').val()
},

Browser other questions tagged

You are not signed in. Login or sign up in order to post.