This is really frustrating, I would appreciate help on this. I have a div called comments and form inside this div. What I want to do is submit the form to the current page and load it inside the div without reloading the whole thing. Here is my current code:
<div id="comments">
<form action="#" method="post" onsubmit="return false;" >
<input type="hidden" name="txtname" value="test">
<textarea id="wysiwyg" name="wysiwyg" rows="5" cols="50"></textarea>
<input type="submit" name="post" id="post" value="Submit">
</form>
<script type="text/javascript">
EDIT: Read edit below for current code
</script>
</div>
When I send a message, a warning is triggered, but the page does not load. It works fine if I do this event as follows:
$("#comments").load("comments.asp");
I do not like the publication of data. I used .load before but never sent data. I got the above code from the same forums.
I'm honestly not sure about the purpose of "name" and "tel" - do I refer to these variables or the names of form variables when processing the code? This is in the ASP classic.
, POST? !
EDIT:
:
$("#post").submit(function(event){
var $form = $(this),
$inputs = $form.find("input, select, button, textarea"),
serializedData = $form.serialize();
$inputs.attr("disabled", "disabled");
$.ajax({
url: "/comments.asp",
type: "post",
data: serializedData,
success: function(response, textStatus, jqXHR){
console.log("comment posted");
},
error: function(jqXHR, textStatus, errorThrown){
console.log(
textStatus, errorThrown
);
},
complete: function(){
$inputs.removeAttr("disabled");
}
});
event.preventDefault();
});
... comments.asp. div ( div?)