I am trying to put AJAX results to
I am getting error in console.
CodePudding user response:
You need action
parameter in your ajax call :
let selectEle = cellEle.children("select").select2({
ajax: {
url: "/wp-admin/admin-ajax.php",
data: {
'action' : 'get_data',
}
dataType: 'json',
processResults: function(data) {
return {
results: data
};
},
}
});
The value of action in JS refers to "wp_ajax_get_data" and "wp_ajax_nopriv_get_data" action names.