开发者

JQuery Ajax Request

I currently have a link:

<a href="view.php?page=1">Click Here<a>

What I need is to do the same thing using ajax so that I don't have to go to a different url and still get the same result.

UPDATE:

I have page A and page B

On page A I have a link to page B

<a href="view.php?page=1">Display P开发者_JS百科age B<a>
<div id="page-b-goes-below">
Page B goes here
</div>

Can the above be done please?


HI,

You cant change a pages complete html with ajax, and the script in the ajax file won't be executed. so you have to make some tricks
some thing like iframe or a master div.

if you wish to use iframe ajax is no need.

still you need this in ajax what you have to do is.
1. ajax files should have only the body content not even the body tag.
2. have a div next to body tag of the first page and load all the file with ajax in that div.

Example:
First or Initial page.
<html>
..........
..........
<body>
    <div id="ajax-container">
        you content comes here..
        ........................
        ........................
    </div>
    <script>
    $(document).ready(function() {
        init_linkhandler();
    });
    function init_linkhandler() {
        $('a').click(function() {
            $('#ajax-container').load($(this).attr('href'));
            init_linkhandler();
            return false;
        });
    }
    </script>
</body>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜