tags:

views:

80

answers:

1

ok i am loading a separate page with links in it, into a page named index.php. it loads fine, but when i click one of the links inside the loaded content, nothing happens. they dont act as links. but if i do a alert('hi'); after the load('page.html'); then it will work. any ideas on getting this to work without alerting something after it loads? oh also i cant use a callback, unless there is a way to update the get variable because the page loading, has a $_GET variable, and the links inside the loaded page are supposed to update the $_GET variable. anyways is there a way to make the links clickable after loading the page?

    function load_file(dirval) {
        $.ajax({
        url: "data.php",
        data: {dir: dirval},
        success: function(data) {
            $('#remote-files').html(data);
        }
        });
    }
+1  A: 

http://api.jquery.com/load/ - has an example of what you're trying to do.

You should be able to pass data on the query string.

Example index.php

<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"&gt;&lt;/script&gt;
<script type="text/javascript">

    $(document).ready(function() {
    function load_file(dirval) {
        $.ajax({
            url: "data.php",
            data: {dir: dirval},
            success: function(data) {
                $('#data').html(data);
            }
        });
    }

    load_file('http://mysite.com');
    });

</script>
</head>
<body>
<div id="data"></div>
</body></html>

data.php

<html>
<head>
</head>
<body>
<ul>
    <li><a href="<?php echo $_GET['dir'] ?>/link.html">Link </a></li>
</ul>
</body>
</html>
Jonathan
i know i can pass the get variables, but once the data is loaded, the content inside is not clickable.
john morris
thats not what im trying to do. can we stick to why the links are not clickable?
john morris
what is the value of `dirval`?
Jonathan
edited code sample above, links are usable.
Jonathan
load_file('/');loads a directory, think of this as like ftp, and it displays folders, and when you click on one, it opens up the new directory
john morris
So does that mean you want the generated links to pass information back to the `load_file` function?
Jonathan