on click from link imported
I am trying to set html when a link is clicked on. I found out that .on should work. Here are my two pages that I have setup for testing:
- <script>
$(function() {
$("#search").on( "click", function(){
$.ajax({ url: 'process.php',
data: { test : 1},
type: 'post',
success: function(output) {
if(output){
$('#stuff').html(output);
}
}
});
});
$('[id^="delRec"]').on( "click", function(){
alert('good');
e.preventDefault();
});
});
</script>
<div id="search">Test</div>
<div id="stuff">
</div>
- $test = $_POST['test'];
if($test){
echo '<a href="" id="delRec"">CLICK HERE</a>';
}