0
I have a basic form, and wanted to change the contents of the div after clicking on the send form, when I run without Submit works, poem with Submit does not work
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#btnenviar").click(function(e){
$("#formenvio").submit();
$("#frame2").load("quiz.html");
e.preventDefault();
});
});
</script>
</head>
<body>
<div id="frame2">
<form id="formenvio" class="form-horizontal" >
<fieldset>
<legend>Form Name</legend>
<div class="form-group">
<label class="col-md-4 control-label" for="textinput">Text Input</label>
<div class="col-md-4">
<input id="textinput" name="textinput" type="text" placeholder="placeholder" class="form-control input-md">
<span class="help-block">help</span>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="singlebutton">Single Button</label>
<div class="col-md-4">
<button id="btnenviar" name="singlebutton" class="btn btn-primary">Button</button>
</div>
</div>
</fieldset>
</form>
</div>
</body>
</html>
I did this but still it does not load the quiz.html after sending
– Igor Oliveira
What does form Submit do? not have an action? If you put a.log console in the ajax call Success, it appears in the browser console?
– Rui Ferreira
I haven’t got the action ready yet
– Igor Oliveira
@If you use the Form tag in html, you must have one e. preventDefault();
– N. Dias
@Ruiferreira worked after putting the console log
– Igor Oliveira
On the #btnenviar button put type="button"
– Rui Ferreira
The.log console is just a print for the console, that’s not what you solved for sure, but I’m glad you helped!
– Rui Ferreira
@Igoroliveira enter no input probably also generates a form Ubmit, note this
– N. Dias
It was this then, I removed the fields of dento from the form
– Igor Oliveira
Just change the Form tag to a div, if it’s not useful, like the answer q gave. vlw
– N. Dias
But then put type="button" on the button and no longer send the form Ubmit
– Rui Ferreira