I have such script that works ok but after success I cannot do anything with the js until refresh the page.
My code looks as follow:
<script>
$("#submit_comment").click(function() {
var url = "{$sitepath}/comment.php"; // the script where you handle the form input.
$.ajax({
type: "POST",
url: url,
data: $("#cform0").serialize(), // serializes the form's elements.
success: function(data)
{
$("#myHeader").load(location.href + " #myHeader > *", "");
}
});
return false; // avoid to execute the actual submit of the form.
});
</script>
It works if I change the
$("#myHeader").load(location.href + " #myHeader > *", "");
to:
$("#myHeader").load("#myHeader");
but then myHeader appears again in myHeader on page.
The question. Is there any possible to load the myHeader and keep the JS on site(sesion)?
Thanks for any suggestions.