Bom dia, estou criando um CRUD e no momento de criar meu update os seguintes erros aparece
index.html:22 Uncaught ReferenceError: viewData is not definedonload @ index.html:22
index.html:120 Uncaught SyntaxError: Unexpected token function
E minha tabela não aparece a não ser que eu comente o formulario no documento server.php entre a linha 47 e 81
segue o codigo do meu index.html e do meu server.php
INDEX.HTML
<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metahttp-equiv="X-UA-Compatible"content="IE=edge"><metaname="viewport"content="width=device-width, initial-scale=1"><!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --><title>CRUD AJAX</title><!-- Bootstrap --><linkhref="css/bootstrap.min.css"rel="stylesheet"><!-- Latest compiled and minified CSS --><!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --><!-- WARNING: Respond.js doesn't work if you view the page via file:// --><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]--></head><bodyonload="viewData()"><divclass="container"><p></p><buttonclass="btn btn-primary"data-toggle="modal"data-target="#addData">Insert DATA</button><!-- Botão para inserir os dados--><!-- Modal --><divclass="modal fade"id="addData"tabindex="-1"role="dialog"aria-labelledby="addLabel"><divclass="modal-dialog"role="document"><divclass="modal-content"><divclass="modal-header"><buttontype="button"class="close"data-dismiss="modal"aria-label="Close"><spanaria-hidden="true">×</span></button><h4class="modal-title"id="addLabel">Insert Data</h4></div><formmethod="POST"><!-- Começo do Formulario --><divclass="modal-body"><divclass="form-group"><labelfor="nm">Full Name</label><inputtype="text"class="form-control"id="nm"placeholder="NAME"></div><divclass="form-group"><labelfor="em">EMail</label><inputtype="email"class="form-control"id="em"placeholder="Email"></div><divclass="form-group"><labelfor="hp">Phone Number</label><inputtype="number"class="form-control"id="hp"placeholder="Phone Number"></div><divclass="form-group"><labelfor="al">Address</label><textareaclass="form-control"id="al"placeholder="Address"></textarea></div></div><divclass="modal-footer"><buttontype="button"class="btn btn-default"data-dismiss="modal">Close</button><buttontype="submit"onclick="saveData()"class="btn btn-primary">Save changes</button></div></form><!-- Termino do Formulario--></div></div></div><divid="result"></div><p></p><tableclass="table table-bordered table-striped"><thead><tr><thwidth="40"></th><th>Name</th><th>Email</th><th>Phone</th><th>Address</th><thwidth="180">Action</th></tr></thead><tbody></tbody></table></div><!-- jQuery (necessary for Bootstrap's JavaScript plugins) --><scriptsrc="js/jquery-3.1.1.min.js"></script><!-- Include all compiled plugins (below), or include individual files as needed --><scriptsrc="js/bootstrap.min.js"></script><script>/* Começo AJAX */function saveData(){var name = $('#nm').val();var email = $('#em').val();var phone = $('#hp').val();var address = $('#al').val();
$.ajax({
type:"POST",
url:"server.php?p=add",
data:"nm="+name+"&em="+email+"&hp="+phone+"&al="+address,
success:function(data){
viewData();}});}function viewData(){
$.ajax({
type:"GET",
url:"server.php",
success:function(data){
$('tbody').html(data);}});}function updateData(str){var id = str;var name = $('#nm-'+str).val();var email = $('#em-'+str).val();var phone = $('#hp-'+str).val();var address = $('#al-'+str).val();
$.ajax({
type:"POST",
url:"server.php?p=edit",
data:"nm="+name+"&em="+email+"&hp="+phone+"&al="+address+"&id="+id,
success function(data){
viewData();}});}</script></body></html>
Question
Mateus Guedes da Conceição
Bom dia, estou criando um CRUD e no momento de criar meu update os seguintes erros aparece
index.html:22 Uncaught ReferenceError: viewData is not definedonload @ index.html:22
index.html:120 Uncaught SyntaxError: Unexpected token function
E minha tabela não aparece a não ser que eu comente o formulario no documento server.php entre a linha 47 e 81
segue o codigo do meu index.html e do meu server.php
INDEX.HTML
SERVER.PHP
Att,
Mateus Guedes
Edited by Mateus Guedes da ConceiçãoLink to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.