jQuery POST php mysql (mobile)

Asked

Viewed 103 times

0

I’m trying to do a post with jQuery mobile on my internal server, when I run the post by the browser it inserts the registry running 100% with exactly the same code, now when I do the test in the simulator (Intel XDK) and also with the APP Preview on my mobile the POST does not work, just nothing happens.

register html.

<!DOCTYPE html>

Blank Standard HTML5 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>
<script src="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!";
}

Am I performing the post correctly ? Is there any other specific method to perform this POST ?

1 answer

0

Friend, where is the test server that you are using "192.168.0.10"? If you are in your machine you will only be able to use by the browser of your machine even, probably the phone is not able to find "192.168.0.10" because it is in your machine that.

Browser other questions tagged

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