Hi,
I am confused on why my function is not being executed. I have setup the AJAX to insert data into the database and on success to grab information from the database and print it out on the site, but I also added a function to be called or executed on ajax Success.
Function update_div():
function update_div()
{
$.ajax({
type: "GET",
url: "new_info.php",
success: function (html) {
if(html)
{
var newDiv = $('<div>').html(html);
$('#new-news').after(newDiv).fadeIn('slow');
}
}
});
}
Please take a look at the snippet below:
function status_post() {
var element = $('#my-div');
var id = element.attr("title");
var status = $('textarea#status').val();
var dataString = 'user_id='+ id + '&status=' + status;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "post_comment.php",
data: dataString,
//On Success: clear textarea and send another AJAX to update Div with new comment
success: function() {
//Clears textarea
$('textarea#status').val('');
///On Success: update a div
$.ajax({
type: "GET",
url: "update.php",
success: function(status_upd) {
var newStatus = $('<div>').html(status_upd);
$('.new-status').after(newStatus).fadeIn('slow');
return false;
}
});
return false;
}
});
//Function will not execute, "What am I doing wrong?"
update_div();
}
Thanks for any advise.
-Programmer12