I'm trying to make a post with jQuery mobile on my internal server, when I run the post through the browser it inserts the registry working 100% with exactly the same code, now when I test the simulator (< in> Intel XDK ) and also with the APP Preview on my mobile the POST does not work, just nothing happens.
registrar.html
<!DOCTYPE html>
HTML5 Standard Web App Template
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=no">
<style>
@-ms-viewport { width: 100vw ; min-zoom: 100% ; zoom: 100% ; } @viewport { width: 100vw ; min-zoom: 100% zoom: 100% ; }
@-ms-viewport { user-zoom: fixed ; min-zoom: 100% ; } @viewport { user-zoom: fixed ; min-zoom: 100% ; }
</style>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script><scriptsrc="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript">
function post() {
var nome = $('#nome').val();
var email = $('#email').val();
var banco = $('#banco').val();
var agencia = $('#agencia').val();
var conta = $('#conta').val();
var telefone = $('#telefone').val();
var senha = $('#senha').val();
$.post('http://192.168.0.10/enviar.php',{nome:nome,email:email,banco:banco,agencia:agencia,conta:conta,telefone:telefone,senha:senha},
function(data){
alert(data);
});
}
<div data-role="footer">
<br />
<br />
<h1>Crie sua conta</h1>
</div>
<form method="post" action="#">
<label>Nome:</label>
<input type="text" name="nome" id="nome" placeholder="">
<label>Email:</label>
<input type="email" name="email" id="email" placeholder="">
<label>Banco:</label>
<input type="text" name="banco" id="banco" placeholder="">
<label>Agência:</label>
<input type="number" name="agencia" id="agencia" placeholder="">
<label>Conta:</label>
<input type="number" name="conta" id="conta" placeholder="">
<label>Telefone:</label>
<input type="tel" name="telefone" id="telefone" placeholder="">
<label>Senha:</label>
<input type="password" name="senha" id="senha" placeholder="">
<a class="ui-btn ui-mini ui-btn-b" onclick="post();">Registrar</a>
</form>
<a href="index.html" class="ui-btn ui-mini" data-rel="back">Voltar</a>
Code (beckend) of my php that inserts:
send.php
<?php
$nome = $_POST['nome'];
$email = $_POST['email'];
$telefone = $_POST['telefone'];
$banco = $_POST['banco'];
$agencia = $_POST['agencia'];
$conta = $_POST['conta'];
$senha = $_POST['senha'];
$conexao = mysql_pconnect("localhost","root","") or die (mysql_error());
$banco = mysql_select_db("aplicativo");
$nome = mysql_real_escape_string($nome);
$email = mysql_real_escape_string($email);
$telefone = mysql_real_escape_string($telefone);
$banco = mysql_real_escape_string($banco);
$agencia = mysql_real_escape_string($agencia);
$conta = mysql_real_escape_string($conta);
$senha = mysql_real_escape_string($senha);
$insert = mysql_query("insert into usuarios (nome,email,telefone,banco,agencia,conta,senha) values ('{$nome}','{$email}','{$telefone}','{$banco}','{$agencia}','{$conta}', '{$senha}')");
mysql_close($conexao);
if($insert) {
print "Cadastro Realizado!";
}else {
print "Erro ao Cadastrar!";
}
I'm done the post correctly? Is there any other specific method to perform this POST?