i would like to call a php page from an Ajax method : the alert works fine, the code as well has been tested outside of wordpress, but here it seems that the php page is never called.
I found some articles, among them : How to manage ajax calls and JSON in wordpress
but i get more confused. Can you please tell me what should i do here? (with “diapo.php” it doesn’t work, and like that neither)
here is the call with jquery :
$('.sous-cat').find('img').click(function(){
var alt_p = $(this).attr('alt');
//alert(alt_p);
$.ajax({
type: "POST",
url: "<?php bloginfo( 'template_directory' ) ?>/diapo.php",
data: {p:alt_p},
success: function(data) {
alert(data);
}
});
return false;
});
and the php page for now :
<?php
/*
$p = $_POST['p'];
query_posts( 'cat=3&p=$p' );
while (have_posts()) : the_post();
$result = the_post_thumbnail('normal');
endwhile;
wp_reset_query();*/
echo '$result';
?>
Thanks for your help