• 0

Javascript from remote script


Question

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)

&lt;script type="text/javascript"&gt;
  var a = location.search.slice(1).split("&amp;"), GET = [];for (i in a) { GET[a[i].split("=")[0]] = a[i].split("=")[1]; }

    		$.ajax({
    			type: "POST",
    			url: "get.php",
    			data: 	"start=" + start + "&amp;term=" + GET["term"] + "&amp;end=" + end,
    			success: function(html){
    				$("#content").html(html); 
    			}
    		});

	$('#popup').hide();

    		$('a').click(function(){
    		$('#popup').show('slow');
    		});

    		$('a#close').click(function(){
    		$('#popup').hide('slow');
    		})
    })
&lt;/script&gt;



(later on the page)

&lt;div id="content"&gt;&lt;/div&gt;
&lt;div id="popup"&gt;&lt;p&gt;&lt;a href="#" id="close"&gt;Close&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;

Then In get.php

echo "&lt;a href=\"#\" id=\"click\"&gt;&lt;img src='/labs/snapshot/includes/image.php?img_id=" . $img_id . "'&gt;&lt;/a&gt;";

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

There have been no answers to this question yet

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.