I am trying to pass value through an ajax json array but value of catergory variable is not getting in controller action
var category = $('#category').val();
var url = $('#ajax_action_search').val();
$.ajax({
type: "POST",
data: {
'category': category
},
dataType: "json",
cache: false,
contentType: false,
processData: false,
success: function(response) {}
});
4
Answers
Just make the following changes :
Please check the Controller action if
category
(parameter name) passed from the ajax is exactly same in the controller action tooYou need to use the parameter namespace matching your extension/plugin:
But you’ll also need to configure the
cHash
evaluation since this will lead to a HTTP request like/?tx_myext_foo[category]=X
which will fail without a matchingcHash
.This can be done with the
excludedParameters
configuration option.You need to make ajaxurl with action and controller. and then pass the data in full format.