I need to load content from a text area into a div via jquery ajax. The content initally loads into a div via jquery. When the button is pressed, a click function inserts the content into a database via ajax and then reloads the content back into the div. It works but seems to be a bit sporadic. My question is, is there a better way to do this.
I am basically trying to submit a status into a timeline without refreshing the page
<script>
$.ajaxSetup ({ cache: false });
var ajax_load = "<div align='center'><img src='img/ajax-loader.gif' alt='loading...' /></div>";
var loadUrl = "ajax/ajax.php";
var loadMe = "functions/status.php";
$("#result").html(ajax_load).load(loadUrl);
$("#share-but").click(function() {
var status = $("textarea#status").val();
$.post(
loadMe,
{ status: status, user_id: '<?php echo "10" ?>' },
"html"
);
$("#result").html(ajax_load).load(loadUrl);
$("textarea").val('Share an update');
});
</script>