I am using $.post to post some data into the server and if that php file works then I am returned with some html snippet. Now the problem lies within the $.post code. I can’t insert the returned data from the php file onto the original file that contains the $.post code. Firebug shows that the html snippet does return back but I’m seeing it on my screen. What’s the problem?
Here is the code below for the file containing the .post()
<script type="text/javascript" >
$.post('ajax_send_band_request.php', {
user_id : user_id,
band_request: band_request,
where_to_go: where_to_go,
when_start: when_start,
when_end: when_end,
time: time
}, function(data){
$(data).find('#message_return').appendTo("#response_from_request_verification")
})
});
</script>
<div id="response_from_request_verification"></div>
Here is the summarized php file version.
if(this_function_sends the data to the server($register_data) === true);
{
?>
<div id="message_return">Request sent!!</div>
<?php
} else
{
?>
<div id="message_return">Request was not sent!</div>
<?php
}
?>
Remove the
.find()part, you already have thediv#message_returnwith $(data)..find()doesn’t check the root element for a match, just descendants.