loading content from php file with jQuery

Posted by Billa on Stack Overflow See other posts from Stack Overflow or by Billa
Published on 2011-01-03T01:00:29Z Indexed on 2011/01/03 1:53 UTC
Read the original article Hit count: 544

Filed under:
|

The following code fetch all data (by clicking a.info link) from a php file "info.php" and prints in the #content div. The problem is that it prints everything from info.php file. Can I possibly select only some part of data from info.php file to load in #content? The reason to ask this question is that, I want to load different data from the same php file for the different links.

$("a.info").click(function(){
var id=$(this).attr("id");
$("#box").slideDown("slow");

$.ajax({
    type: "POST",
    data: "id="+$(this).attr("id"),
    url: "info.php",
    success: function(html){
        $("#content").html(html);
    } 
});
});

Html where content is loading:

   <div id="box">
    <div id="content"></div>
    </div>

info.php

paragraph1.
    paragraph2.

For example, In the above info.php file, i only want to load paragraph1 in the #content.
I hope my question is clear. Any help will be appreciated.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery