Answer the question
In order to leave comments, you need to log in
How to convert an array to json and get the same array in php?
Hey! There have already been a lot of things on this topic, but I'm already confused and tried to solve the problem in different ways, but it doesn't work. In general, there is an array and this is ajax:
var cat = ["flats", "underground", "houses"];
var post_type = $(this).data('post-type');
$.ajax({
type : "post",
context: this,
dataType : "json",
url : ajaxurl,
data : {
action: "filter_hobby",
post_type: post_type,
post_term: JSON.stringify($.extend({}, cat))
},
beforeSend: function(data) {
$('.areas').css('opacity', '1');
},
success: function(response) {
var $newElems = $(response.html);
$('.areas').html($newElems);
$('.areas').css('opacity', '1');
}
});
json_decode($_REQUEST['post_term'])
Answer the question
In order to leave comments, you need to log in
post_term: cat
instead ofpost_term: JSON.stringify($.extend({}, cat))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question