doubiaode0460 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.)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答