I'm trying to using submit post in ajax ( properly jQuery .load() function ) but I have a problem because after the page .load (see below) submit button >>to .click(function() doesn't work. Does anyone have any idea how to solve that?
Here is my entire code:
<script src="{$sitepath}/scripts/jquery.min.js"></script>
<div id="newswhite">
<form name="cform0" id="cform0" method="post" enctype="multipart/form-data">
<textarea name="text1" class="form-control"></textarea>
<input type="submit" id="submit_comment" class="btn" name="submit" value="comment">
</form>
</div>
<script>
$("#submit_comment").click(function() {
var url = "some.php";
$.ajax({
type: "POST",
url: url,
data: $("#cform0").serialize(),
success: function(data)
{
$("#newswhite").load(" #newswhite >*");
//$("#newswhite").html(data);
}
});
return false;
});
</script>
It all works just once. After .load I have to refresh the page by browser... Any idea?