Here is the code to fetch a bunch of < a > tags which contains ID's and those ID's are use to fetch more data from the same file.. So to make this short as possible
index.html
var strURL ="co.php";
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.status == 200) {
document.getElementById('content').innerHTML=req.responseText;
}
};
req.open("GET", strURL, true);
req.send(null);
}
with that code I get my external file which contains something like this.
co.php
<div>
<a href="#" class="l" id="c1">Link 1</a>
<a href="#" class="l" id="c2">Link 2</a>
<a href="#" class="l" id="c3">Link 3</a>
<a href="#" class="l" id="c4">Link 4</a>
</div>
<script>
$(".l").click(function () {
alert($(this).attr("id"));
});
</script>
and thats all that is for the co.php file... I can see the links but the script just doesn't work... and I wonder why... now that script is prefer to be in the index.html and not in the co.php file... but the result is the same.. if the script is in index.html it doesn't work, so how can I make it work? ... like I said I prefer that
<script>
$(".l").click(function () {
alert($(this).attr("id"));
});
</script>
be in the index.html and make it work with the file that is from pull with ajax...