I want to access a photo gallery by clicking on the gallery icon, and for this I use the following jQuery code:
<script type="text/javascript">
$(document).ready(function(){
$('.galbt a').on('click', function(e) {
var gallery = $(this).parent().find("p").text();
//$("#section").load("gallery.php"); // I tried puting this here
$.ajax
({
url: "gallery.php",
type: "POST",
data: { "galeria" : gallery },
success: function(){$("#section").load("gallery.php");} // or here
})
});
});
</script>
The php file takes the galery name, scann the directory and build a modal carousel by echoing it. PHP page loads but doesn't shows anything (I mean it shows a little html part that doesn't depend of the variable, but does not show the part that needs the variable to be shown). I tryed loading it first and then posting the variable, or first posting the variable and then loading it, but no change have been seen.
And another question I got is... there is any difference if I change the extension to html or php? Because php file has a combined code and I tried loading it as both, like PHP or HTML and result is the same (nothing is shown).
Thanks.
.htmlisn't going to servePHP, it will just output the PHP unprocessed (unless you modified the handler).loadbecause both are independent calls .simply use load like this:$("#section").load("gallery.php?galeria="+gallery);without outer ajax.