I tried to do as on the codex but I must have a little problem somewhere .. Same problem as above, the data is sent but never reaches its destination..
Thanks for your help =)
ajax.js :
function sendSearch(){
var search = document.getElementById('search').value;
jQuery(document).ready(function($) {
$.ajax({
url: '/integrationWP/wp-admin/admin-ajax.php',
method : 'POST',
data:{
'action':'doAjax',
'value': search
},
success: function(data){
// alert('?a fonctionne !');
},
error: function(errorThrown){
alert('error');
console.log(errorThrown);
}
});
});
}
document.getElementById('submit').addEventListener('click', function(){
sendSearch();
document.getElementById('search').value = "";
})
PHP file :
` add_action('wp_ajax_nopriv_doAjax', 'get_data');
add_action('wp_ajax_doAjax', 'get_data');
function get_data(){
if(isset($REQUEST)){
$search = $REQUEST['value'];
echo 'Hello';
}
die();
}
`
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…