WordPress
I have a ajax function passing value to a function in functions.php The function on functions.php sends the response to ajax success but the value I am passing using ajax is not going to the function in functions.php
$.ajax({
url: ajaxStuff.ajaxurl,
type: "GET",
processData :true,
data: {
action: 'filter_package',
value: data,
},
success: function (data) {
alert(data);
},
});
The console.log for data shows as:
{cat_names: Array(1), reg_names: Array(0), dest_names: Array(0), fromPrice: '', toPrice: '', …}
which is correct one.
If I enter some hardcoded message to my filter_package function in functions.php the ajax shows the response which means the ajax function hits my function on functions.php but when I try to get the data from ajax on my function I shows Array0
function filter_package()
{
$value = $_REQUEST['value'];
$cat_slug = $value['cat_names'];
echo 'sadasd'.$cat_slug;
The output:
sadasdArray0