I want to get a div element with an ID after calling $.ajax()
Here is my code:
$.ajax({
url: "PO_Header.php",
data: "supplier="+selectedId,
cache: false,
success: function(html){
$("#PO_Header").empty();
$("#PO_Header").append(html);
}
});
$("#PO_Header").append(html); will append the entire html page, what I want to have is get an element with a specific id. Let’s say inPO_Header.phpa div element with an id='mydiv' would be injected in my current page.
Use jQuery’s load:
It allows you to load page fragments. As their documentation points out:
It will therefore only inject
<div id="myDiv"></div>from PO_Header.php into your element.