Après chargement avec $.ajax()
Bonjour,
Je charge du contenu dynamique dans la div ayant pour id #notification avec la fonction $.ajax lors du clique sur un des 3 bouttons ayant pour class plop
Le contenu chargé c'est un bouton ayant pour id #test.. Mais lorsque je clique sur celui-ci l'action ne se fait pas (dans ce cas afficher une alert()).
J'aimerais savoir d'où vient mon problème ?
Merci de votre aide.
Voici mon code :
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans nom</title>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script>
// JavaScript Document
$(document).ready(function() {
$('.plop').click(
function(){
var id = $(this).val();
var dataString = 'id='+id;
$.ajax({
type: "POST",
url: "action.php",
data: dataString,
success: function(msg){
$('#notification').html(msg);
},
error: function(){
alert("Erreur, veuillez recommencer");
}
});
}
);
$('#test').click( function(){alert('TEST REUSSI');});
});
</script>
</head>
<body>
<button class="plop" value="10">10</button>
<button class="plop" value="15">15</button>
<button class="plop" value="20">20</button>
</tr></table>
<br /><br /><br />
<div id="notification">Ici</div>
</body>
</html> |
et mon script action.php qui contient ce qui va être charger dans la div #notification :
Code:
1 2 3 4 5 6
|
<?php
echo '<button id="test">'.$_POST['id'].'</button>';
?> |