SQL error in fullcalendar connection

Asked

Viewed 52 times

2

My code is returning false, I’ve debugged but I can’t find the error he returns "There was some problem.."

<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="utf-8">
    <meta name="description" content="Miminium Admin Template v.1">
    <meta name="author" content="Isna Nur Azis">
    <meta name="keyword" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Miminium</title>
    <link rel="stylesheet" type="text/css" href="asset/css/bootstrap.min.css">
      <link rel="stylesheet" type="text/css" href="asset/css/plugins/font-awesome.min.css"/>
      <link rel="stylesheet" type="text/css" href="asset/css/plugins/simple-line-icons.css"/>
      <link rel="stylesheet" type="text/css" href="asset/css/plugins/animate.min.css"/>
      <link rel="stylesheet" type="text/css" href="asset/css/plugins/fullcalendar.min.css"/>
    <link href="asset/css/style.css" rel="stylesheet">
    <link rel="shortcut icon" href="asset/img/logomi.png">
    <link rel='stylesheet' href='fullcalendar/fullcalendar.css' />
    <script src='fullcalendar/lib/jquery.min.js'></script>
    <script src='fullcalendar/lib/moment.min.js'></script>
    <script src='fullcalendar/fullcalendar.js'></script>

    <script src='fullcalendar/lang/pt-br.js'></script>

    <script>
       $(document).ready(function() {   

            //CARREGA CALENDÁRIO E EVENTOS DO BANCO
            $('#calendario').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
                defaultDate: '2017-10-12',
                editable: true,
                eventLimit: true, 
                events: 'eventos.php',           
                eventColor: '#dd6777'
            }); 

            //CADASTRA NOVO EVENTO
            $('#novo_evento').submit(function(){
                //serialize() junta todos os dados do form e deixa pronto pra ser enviado pelo ajax
                var dados = jQuery(this).serialize();
                $.ajax({
                    type: "POST",
                    url: "cadastrar_evento.php",
                    data: dados,
                    success: function(data)
                    {   
                        if(data == "1"){
                            alert("Cadastrado com sucesso! ");
                            //atualiza a página!
                            location.reload();
                        }else{
                            alert("Houve algum problema.. ");
                        }
                    }
                });                
                return false;
            }); 
       }); 

    </script>

    <style>
        #calendario{
            position: relative;
            width: 70%;
            margin: 0px auto;
        }        
    </style>
  </head>
 <body id="mimin" class="dashboard">
        <nav class="navbar navbar-default header navbar-fixed-top">
          <div class="col-md-12 nav-wrapper">
            <div class="navbar-header" style="width:100%;">
              <div class="opener-left-menu is-open">
                <span class="top"></span>
                <span class="middle"></span>
                <span class="bottom"></span>
              </div>
                <a href="perfil.php" class="navbar-brand"> 
                 <b>Economic life</b>
                </a>
              <ul class="nav navbar-nav search-nav">
                <li>
                </li>
              </ul>
              <ul class="nav navbar-nav navbar-right user-nav">
                <li class="user-name"><span><?php echo $_SESSION['nome_usu']; ?></span></li>
                  <li class="dropdown avatar-dropdown">
                   <img src="asset/img/avatar.jpg" class="img-circle avatar" alt="user name" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"/>
                   <ul class="dropdown-menu user-dropdown">
                     <li><a href="perfil.php"><span class="fa fa-user"></span> Meu perfil</a></li>
                     <li><a href="calendar.html"><span class="fa fa-calendar"></span> Meu calendario</a></li>
                     <li role="separator" class="divider"></li>
                     <li class="more">
                      <ul>
                        <li><a href="index.php"><span class="fa fa-power-off "></span></a></li>
                      </ul>
                    </li>
                  </ul>
                </li>
              </ul>
            </div>
          </div>
        </nav>
      <!-- end: Header -->
      <div class="container-fluid mimin-wrapper">
          <!-- start:Left Menu -->
            <div id="left-menu" style="position: absolute; float: left;">
              <div class="sub-left-menu scroll">
                <ul class="nav nav-list">
                    <li><div class="left-bg"></div></li>
                    <li class="time">
                      <h1 class="animated fadeInLeft">21:00</h1>
                      <p class="animated fadeInRight">o</p>
                    </li>
                    <li class="active ripple">
                      <a href="perfil.php" class="tree-toggle nav-header"><span class="fa-home fa"></span> Perfil 
                        <span class="fa-angle-right fa right-arrow text-right"></span>
                      </a>
                    </li>
                    <li class="ripple"><a class="tree-toggle nav-header"><span class="fa fa-table"></span> Tables  <span class="fa-angle-right fa right-arrow text-right"></span> </a>
                      <ul class="nav nav-list tree">
                        <li><a href="handsontable.html">handsontable</a></li>
                      </ul>
                    </li>
                  </ul>
                  </ul>
                </div>
            </div>
          <!-- end: Left Menu -->
          <!-- start: content -->
            <div id="content">
                <div class="panel">

                            <div id='calendario'>
                                <br/>
                                <form id="novo_evento" action="" method="post">
                                    Nome do Evento: <input type="text" name="nome" required/><br/><br/>            
                                    Data do Evento: <input type="date" name="data" required/><br/><br/>            
                                    <button type="submit"> Cadastrar novo evento </button>
                                </form>
                            </div>

                </div>
  • Darlei, unfortunately var_dump is not being recognized, but apparently it does not even enter the ajax

1 answer

0

Hello!

try to give a console.log(data) and make sure you have the browser console open (just give F12 on the Console page and tab). For it may be that the date is empty, or it is not coming from the backend.

Another check would be to validate whether everything is ok with the data being sent, giving a console.log in the var data (var data = jQuery(this). serialize()).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.