How to call a modal from another file?

0

I have a file called principal.php and I have a modal in the file alta.php .

mi boton 
----------
<a class="btn btn-danger" href="javascript:agregar();">Agregar</a>

function agregar(){
	   $('#myModal').modal({
          show:true
        });
$( "#formularioAgregar" ).submit(function( event ) {
      event.preventDefault();
      var frm= $(this).serialize();
      console.log(frm);
       $.ajax({
       type:"POST",
       url: 'index.php?accion=guardar',
       data: frm,
       success: function(data){
        $('#formularioAgregar')[0].reset();
        window.location.replace("index.php?accion=index");
        $('#resp').html('Se Agrego Correctamente El Status').show(200).delay(2500).hide(200);
        //mostrar la respuesta del servidor
        //$('#agregar-registros').html(data);
       }
        })
    });
}

          <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                    <div class="modal-dialog modal-sm" role="document">
                      <div class="modal-content">
                      <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal" aria-hidden="true" >&times;</button>
                          <h4 class="modal-title" id="myModalLabel"><b>Agregar un Categoria</b></h4>
                      </div>
                      <div class="modal-body">
                        <form id="formularioAgregar" role="form">
                          <table border="0" width="100%">

                            <div class="form-group">
                              <label class="control-label">Categoria</label>
                              <input type="text" name="Categoria" class="form-control input-sm" data-error="Es un campo obligatorio" required>
                            </div>
                              <input type="hidden" name="guardar" id="guardar" value="guardar">
                          </table>
                            <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                              <button type="submit" name="enviar" id="agregar" class="btn btn-primary">Agregar</button>
                            </div>
                            <tr>
                              <td colspan="2">
                                  <div id="mensaje"></div>
                            </td>
                            </tr>
                          </form>
                        </div>
                      </div>
                    </div>
                   </div>

How can I access the modal if it is in another file?

    
asked by Carlos Enrique Gil Gil 13.09.2017 в 23:35
source

0 answers