开发者

JQuery load at display page

I'm newbie on web technologies and particular on jQuery so my question can be stupid.

What I want is to call a particular file (using .get or .post jQuery) when I click on some link and also load that file into browser. Also, the browser address should point to that file. This is what I have tried:

$('#my_link').click(
    function(event){
        event.preventDefault();
        $.get("index.php", function(data){
            $(document).html(data);
        });
    }
);
开发者_运维技巧

P.S. I'm using .get/.post because I want to send some param. to that page (index.php), param. used to fill some fields.


I will suggest you, to try .load() method instead. It also provides options for sending params.

Here is an example based on the question.

$('#my_link').click(function() {
   $('#mydiv').load ("index.php", { param1: val1, param2: val2 }, function) {
      alert('loaded');
   });
});

I would suggest to load the contents on a division rather than the document itself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜