I am using ajax post and am receiving data in the form of html. I need to split up the data and place pieces of the data all over the page. I built my response data to be someth
Update: Just realized you should probably do this:
success:function(data) {
data = $('').append(data);
$('#greeting',data).appendTo('#one')
$('#something',data).appendTo('#two')
}
As you cant use .find
properly since it isnt a child but if you append it to an empty node you can. The other alternative would be using .filter
$.ajax({
type:'POST',
url: 'confirm.php',
data: "really=yes&sure=yes",
success:function(data){
$('#greeting',data).appendTo('#one')
$('#something',data).appendTo('#two')
}
});
You can extract from data
and append where you want to. You can also do something like return JSON instead, and instead of extracting html from html just access the html from an object.
$(data.greeting).appendTo('#one')
$(data.something).appendTo('#two')
The response would have to be like:
({ 'greeting':'html', 'something' :'other html' })