I'm having some trouble with some code, and everything I try doesn't seem to work - nor can I find anything online!
I'm using a Jquery AJAX post call to a php file which gets images from a database. Which works fine. I'm then trying to get a lightbox to run, but whenever the code is in the <a href> tags on the external script, it doesn't seem to work.
Page Code:
(in the header)
<script type="text/javascript">
var a = location.search.slice(1).split("&"), GET = [];for (i in a) { GET[a[i].split("=")[0]] = a[i].split("=")[1]; }
$.ajax({
type: "POST",
url: "get.php",
data: "start=" + start + "&term=" + GET["term"] + "&end=" + end,
success: function(html){
$("#content").html(html);
}
});
$('#popup').hide();
$('a').click(function(){
$('#popup').show('slow');
});
$('a#close').click(function(){
$('#popup').hide('slow');
})
})
</script>
(later on the page)
<div id="content"></div>
<div id="popup"><p><a href="#" id="close">Close</a></p></div>
Question
Lloydje25
Hi,
I'm having some trouble with some code, and everything I try doesn't seem to work - nor can I find anything online!
I'm using a Jquery AJAX post call to a php file which gets images from a database. Which works fine. I'm then trying to get a lightbox to run, but whenever the code is in the <a href> tags on the external script, it doesn't seem to work.
Page Code:
(in the header) <script type="text/javascript"> var a = location.search.slice(1).split("&"), GET = [];for (i in a) { GET[a[i].split("=")[0]] = a[i].split("=")[1]; } $.ajax({ type: "POST", url: "get.php", data: "start=" + start + "&term=" + GET["term"] + "&end=" + end, success: function(html){ $("#content").html(html); } }); $('#popup').hide(); $('a').click(function(){ $('#popup').show('slow'); }); $('a#close').click(function(){ $('#popup').hide('slow'); }) }) </script> (later on the page) <div id="content"></div> <div id="popup"><p><a href="#" id="close">Close</a></p></div>Then In get.php
However the hidden div doesn't show when clicked, however if I put tyhe <a href id="click"></a> into the 1st page it works fine.
Thanks for any help.
Link to comment
Share on other sites
0 answers to this question
Recommended Posts