Reputation:
What is wrong with my code?
After clicking the button, I want to hide and show a div
with another result.
This is happening, but is not running the submit code. The field value is not getting propagated.
$(document).ready(function(){
$('#conteudo').hide();
$('#button').click(function(event){
$('form#form1').submit(function(event){
$("#form").hide("slow");
$("#conteudo").show("slow");
event.preventDefault();
});
});
$('#mostrar').click(function(event){
event.preventDefault();
$("#form").show("show");
$("#conteudo").hide("show");
});
});
Upvotes: 0
Views: 204
Reputation:
Unable to do. If a friend has the same problem solved in this way.
$(document).ready(function(){
$('#conteudo').hide();
<?php if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { ?>
$(document).ready(function(){
event.preventDefault();
$("#form").hide("slow");
$("#conteudo").show("slow");
});
<?php } ?>
$('#mostrar').click(function(event){
event.preventDefault();
$("#form").show("show");
$("#conteudo").hide("show");
});
});
Upvotes: 0
Reputation: 13725
http://api.jquery.com/submit/ says:
...so we can cancel the submit action by calling .preventDefault() on the event object or by returning false from our handler. ...
You should remove the preventDefault()
Upvotes: 2