Good evening, I'm a student at JS, html. I'm trying to learn how I can do an inclusion on the server (I apologize if I describe with the incorrect word or term some step). I have to create a website to do a CRUD on the server. I have to implement JAVA SCRIPT Update, Create, Delete, Read. However, I have already done the READ and DELETE. I'm trying to do the CREATE. But I do not think I know any content. I've researched a lot and I can not include anything on the Server.
I'll send my code down:
<!DOCTYPE html>
<html><script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><body><h2>TabelaDeClientes</h2><formid="formularioId">
Nome do cliente:<input type="text" id="form">
uf: <input type="text" id="form" >
Renda Mensal: <input type="text" id="form" >
<button type="submit" id="criarId">Criar</button>
</form>
<br><br> <button type="button" id=tabela>Tabela</button>
<br><br>
Resultado:<br>
<p id="listaCliente" ></p>
<script>
var url="httpEndereço";
$(document).ready(function(){
$("#tabela").click(function(){
$.get("https://clienteweb2017.000webhostapp.com/crud_ajax_json/
getDadosClientes.php")
.done(function(data,status){
var obj = JSON.parse(data);
console.log(obj);
montarTabela(obj);
})
.fail(function(){
alert("Problema de conexão");
});
});
function montarTabela(obj){
var i;
//console.log (response.responseXML);
//var xmlDoc = response.responseXML;
var table="<table border=1 style=border-collapse:'collapse';><tr>
<th>Id</th><th>Nome</th><th>uf</th><th>Renda Mensal</th><th>remover</th>
</tr>";
//var x = xmlDoc.getElementsByTagName("ALBUM");
for (n of obj.data) {
table += "<tr><td>" + n.id +"</td><td>" +n.nome +
"</td><td>" + n.uf +"</td><td>" + n.rendamensal+"</td><td><a
href='#'class='excluir'>remover</a></td></tr>";
}
$("#listaCliente").html(table);
}
$("body").on("click", ".excluir",function(){
var Cid=$(this).parent().siblings(0).html();
$.get("https://clienteweb2017.000webhostapp.com/crud_ajax_json/
deleteCliente.php?id="+Cid)
.done(function(){
//alert("Removido!!!");
})
.fail(function(){
alert("Problema de conexão");
});
});
});//Fim da Ready
var xhttp=new XMLHttpRequest();
$(document).ready(function(){
$("body").on("click", "#criarId",function(){
var criacao=$('#formularioId');
$.get("https://clienteweb2017.000webhostapp.com/crud_ajax_json/
createCliente.php?nome="+criacao)
.done(function(){
//alert("Removido!!!");
})
.fail(function(){
alert("Problema de conexão");
});
xhttp.send();
});
});//Fim da Ready
</script>
</body>