I begin with jQuery and I'm trying develop a web audio player using jQuery, AJAX & PHP,
I have a problem with loading jQuery script included in my DOM after the success of AJAX.
When I receive my data via AJAX, the included scripts in the DOM does not respond.
There is my code:
1: I send my data vi onclick
link to AJAX script :
<a href="" onclick="getfile('<?php echo $file; ?>'); return false;"><?php echo $file?></a>
2- AJAX receive my data with success via this function:
function getfile(audio) {
$.ajax({
type: 'POST',
url: 'script.php',
data: {
song: audio
},
success: function(data) {
$('#playlist1').html(data); // I get data with sucess in playlist1 div but player.js which is supposed to read the link that I got from PHP script is not loaded
},
});
}
I tried to put player.js
in getScript
before AJAX it work but I have a lot of bugs when I click in another link.
My question is: how can I load all my included scripts when the AJAX request completes? I heard about live function, but I don't know how to integrate live()
in my case.