i try to update a list with jquery but for some reason the POST function returns wierd objects. any ideas how to retrieve the data from the POST answer?
var ans = jQuery.post("mysite.com", {name: "John"})
var cont = jQuery( ans ).find( "#content" );
alert(cont);
and the page:
<?php
echo "<div id='content'>";
echo $_POST['name'];
echo '</div>';
?>
it alerts [object], when i try to read all the field of the object with:
answ = '';
for( var key in ans ) {
answ = answ + 'key: ' + key + '\n' + 'value: ' + ans[key];
}
jQuery('#somediv').html( answ );
any ideas how to get what i echoed on the other page?
EDIT: i tried the following as you all suggested:
var ans = jQuery.post("mysite.com", {name: "John"});
jQuery.when(ans).then(function(answ){
var cont = jQuery( answ ).find( "#content" );
alert(cont);
});
and also:
var ans = jQuery.post("mysite.com", {name: "John"}, function(answ){
var cont = jQuery( answ ).find( "#content" ).html();
alert(cont);
});
but it still doesnt work. the alert simply doesnt show which means there is something wrong before it.