jquery and ajax for form submission
Hi ,
$(document).ready(function() {
$('#form').submit(function() {
var number = $('#number').val();
window.setTimeout("ajaxfunction()",1);
return false;
});
});
function ajaxfunction(){
alert('function');
$.ajax({
type:
"post",
url:
"put_file.jsp",
data
:
"type=get",
success:
function(msg) {
$('#result').hide();
$("#result").html("<h3>" + msg + "</h3>")
.fadeIn("slow");
if(msg=="0")
{
//window.setTimeout("ajaxfunction()",100);
}
else
{
return;
}
}
});
}
<form id="form"
action="getajax_file.jsp?type=post" method="post">
Enter number:
<input id="number" type="text" name="number" />
<input id="submit" type="submit" value="Calculate Square Root" name="submit"/>
</form>
For the form submission, can you please let me know is this valid. I have used two different URLs (put_file.jsp and getajax_file.jsp) in the action of the form and the URl for ajax.