Connecting a phone app (phonegap) to a localhost file(in local machine)
<p>I am creating a phonegap mobile app(android).I have emulated the app using my phone.When I do a  registration on the form in local machine it is successfully and data is submitted to database.But when I try to do the same using my phone nothing happens.The reason I think is the phone can't reach the loop back address of my machine.How can I go about this?</p>

<p>registration file (HTML)</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script type="text/javascript"&gt;
    $(document).ready(function(){  
    $("#signup").click(function(){
    var name = $("#name").val();
    var email = $("#email").val();
    var username=$("#username").val();
    var password=$("#password").val();

    // Returns successful data submission message when the entered information is stored in database.
    var dataString = 'name='+ name + '&amp;email='+ email + '&amp;username=' + username + '&amp;password=' + password;

    if(name==''|| email=='' || username=='' || password=='')
    {
        alert("Please Fill All Fields");
    }
    else
    {
        //AJAX code to submit form.
        $.ajax({
                type: "POST",
                url: "http://127.0.0.1/test/signup.php",
                data: dataString,
                cache: false,
                success: function(result){
                                    alert(result);
                                        }
        });
    }
    return false;
    });
    });
&lt;/script&gt;
    
&lt;div class="app"&gt;
        &lt;div class="panel panel-primary"&gt;
            &lt;div class="panel-heading"&gt;
                &lt;h3 class="panel-title"&gt;Sign Up&lt;/h3&gt;
            &lt;/div&gt;
            &lt;div class="panel-body"&gt;
                &lt;div class="form-group"&gt;
                    &lt;input type="text" name="name" id="name" class="form-control" placeholder="Full Name" required&gt;
                    &lt;br&gt;
                    &lt;input type="email" name="email" id="email" class="form-control" placeholder="Email Address" required&gt;
                    &lt;br&gt;
                    &lt;input type="text" name="username" id="username" class="form-control" placeholder="Username" required&gt;
                    &lt;br&gt;
                    &lt;input type="password" name="password" id="password" class="form-control" placeholder="Password" required&gt;
                    &lt;br&gt;
                    &lt;input type="submit" id="signup" value="Submit" class="btn btn-success"&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;b&gt;or Sign In &lt;a href="#" class="btn btn-primary" data-toggle="modal" data-target="#login-mod"&gt;Here&lt;/a&gt;&lt;/b&gt;
        &lt;/div&gt;
    &lt;/div&gt;</code></pre>
</div>
</div>
</p>

<p>Signup file (PHP file)</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
header('Access-Control-Allow-Origin: *');
$con=mysqli_connect("localhost","root","","test") or die("error in server");

 
   $name=$_POST['name'];
   $email=$_POST['email'];
   $username=$_POST['username'];
   $password=$_POST['password'];

    $sql="INSERT INTO signup(name,email,username,password) values('$name','$email','$username',sha1('$password')) ";
    $qry=mysqli_query($con,$sql) or die(mysqli_error($con));
     if($qry){echo "Registration was successful.";}
     else echo "A network error occured.Please retry.";
  
?&gt;</code></pre>
</div>
</div>
</p>