Navigation ajax avec jQuery
Bonjour ma navigation en ajax ne marche pas ...
Je ne c'est pas pourquoi :calim2:
Si vous avez le problème de mon code ou un autre a me proposer je suis preneur :zoubi:
voici mes code :
js :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
$(document).ready(function(){
$("#nav a").click(function(){
var page=$(this).attr("href");
$.ajax({
url: page,
cache: false,
success: function(html){
afficher(html);
},
error:function(XMLHttpRequest,textStatus, errorThrown){
alert(textStatus);
}
})
return false;
});
});
function afficher(data){
$("#contenu").fadeOut (500, function() {
$("#contenu").empty();
$("#contenu").append(data);
$("#contenu").fadeIn(1000);
})
} |
php :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
<div class="Zone-de-texte">
<div id="contenu">
<?php
$d="pages/";
if(isset($_GET['p'])){
$p=strtolower($_GET['p']);
if(preg_match("/^[a-z0-9\-]+$/",$p) && file_exists($d.$p.".html")){
include $d.$p.".html";
}
else{
include $d."404.html";
}
}
else{
include $d."index.html";
}
?>
</div>
</div> |
Merci pour vos réponse 8-)