My question is whether this code is correct.
$(document).ready(function(){
$("#fechar").click(function(e){
e.preventDefault();
String lista_Cont = $(this).attr('<?php include "listaUsuario2.php";?>');
$("#lista").load(this.lista_Cont);
});
});
The function of it is, when I close the modal, where I used to register a new user, it reloads the updated content again, but it is on the same page where it already is.
I have an admin page, where I click on register and go to users, the system in Ajax returns only the content of the changed medium, in this content comes the code where I ready all users already registered and give the option of register new user, if it is chosen, this option opens a modal, where I register new User, but this modal is still open, and when I close it, the page is not updated. I need that when I close it already update the section to min, and enable me to see new users registered immediately.
MY COMPLETE CODE:
<script type="text/javascript">
$(document).ready(function(){
$("#fechar").click(function(e){
e.preventDefault();
String lista_Cont = $(this).attr('<?php include "listaUsuario2.php";?>');
$("#lista").load(this.lista_Cont);
});
});
jQuery(document).ready(function(){
jQuery('#cadUsuario').submit(function(){
var dados = jQuery( this ).serialize();
jQuery.ajax({
type: "POST",
url: "salvarUsuario.php",
data: dados,
success: function( data )
{
alert( data );
}
});
return false;
});
});
</script>
<div class = "conteudo">
<div class="container-fluid">
<div align="left" id="inserir">
<button type="button" class="btn btn-default btn-lg" data-toggle="modal" data-target="#myModal">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Inserir
</button>
</div>
<!-- Listar Usuarios -->
<legend>Úsuarios Cadastrados</legend>
<div id="lista">
<?php include "listaUsuario2.php";?>
</div>
</div>
<!-- Fim listar Usuarios -->
</div> <!-- FECHA CONTEUDO -->
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Novo Úsuario</h4>
</div>
<div class="modal-body">
<div align="center">
<form class="form-horizontal" action="" method="post" id="cadUsuario">
<fieldset>
<!-- Text input-->
<div class="control-group">
<label class="control-label" for="TXT_NOMEX_USUAR"></label>
<div class="controls">
<input id="TXT_NOMEX_USUAR" name="TXT_NOMEX_USUAR" type="text" placeholder="Nome" class="input-large">
</div>
</div>
<!-- Text input-->
<div class="control-group">
<label class="control-label" for="TXT_ENDER_EMAIL"></label>
<div class="controls">
<input id="TXT_ENDER_EMAIL" name="TXT_ENDER_EMAIL" type="text" placeholder="Email" class="input-xlarge">
</div>
</div>
<!-- Password input-->
<div class="control-group">
<label class="control-label" for="TXT_SENHA_USUAR"></label>
<div class="controls">
<input id="TXT_SENHA_USUAR" name="TXT_SENHA_USUAR" type="password" placeholder="Senha" class="input-small">
</div>
</div>
<br>
<br>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" id="fechar">Fechar</button>
<button type="submit" class="btn btn-primary" id="botao_cadUsuario">Salvar</button>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>