2015-07-11 17:15
浏览 76

PHP MYSQL JSON Phonegap登录应用程序

I was trying to make a Phonegap App which has a simple login form, which should ideally connect to a PHP form, and retrieve the user role.

I would like to clarify following things:

  1. My Login Page, written in PHP works fine.
  2. When given the proper credentials as Get parameters, it returns the right JSON tags :


Here is my Phonegap App HTML code. Kindly assist me on where I am going wrong. Assume that the username is username and password is password.

<!DOCTYPE html>
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <title>Hello World</title>
        <div class="app">
        <input id="username" name="username"placeholder="Email"></input>
        <input id="password" name="password"type="password" placeholder="Password"></input>
        <input type="button" value="Login" id="btnLogin"/>
<div id="myDate"></div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
    $( "#myDate" ).text( "Reached Here" );
error: function(error)


How the App should perform is, when I click the button, it calls the jquery code, which generates an AJAx request to the php file and retrieves a JSON string, which I intend to only pop as alert, as of now.

However, clicking the button does absolutely nothing.

I am hardcoding the username and password now but can and will take it from fields later on. Need to test this first before I do that though. Kindly assist on where am I going wrong.

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douzhi1919 2015-07-15 06:06

    If nothing is happening then the problem is with the click function, otherwise the ajax call would have displayed an error. I say try getting rid of the $(document).ready(function() and put the js/jquery-2.1.4.min.js in the head (which by the way does not have a starting tag.)

    打赏 评论
  • doulan8330 2015-07-11 17:43

    Note: It would help a lot if you included the errors that you are receiving, or a description of the ways that your code is not functioning as expected.

    That being said, the only error I can immediately see in that code is that your url parameter is formatted incorrectly. Instead of this:


    It should be this:

    打赏 评论

相关推荐 更多相似问题