1

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.

1
  • you can control the ouput in info.php (which mean ouput paragaph1 only) ... Commented Jan 3, 2011 at 1:08

1 Answer 1

1

Assuming paragraph1 is a div element, change accordingly:

success: function(html){
    var p1 = $(html).find("div#paragraph1");
    $("#content").html(p1);
} 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.