我是一个开发Android应用程序的团队,该应用程序将极大地依赖于远程数据库的使用.我们正在使用PhoneGap和Jquery Mobile,并尝试使用AJAX和JSON调用连接到我们的MySQL数据库.目前,我们在测试阶段遇到了麻烦,即通过MySQL Workbench从mySQL /输入中提取"Ted"的硬编码用户来验证我们甚至可以建立连接.
根据我们收集的信息,数据传输过程如下:
在我们的html文件中,我们有一个
<script type="text/javascript" src="Connect.js"></script>
Run Code Online (Sandbox Code Playgroud)
^哪个应该运行Connect.js脚本,对吗?那么,从那里开始运行Connect.js?
Connect.js运行,将其连接到托管在外部Web服务上的ServerFile.php,允许它运行PHP以连接到MySQL数据库并提取信息.
//run the following code whenever a new pseudo-page is created
$('#PAGENAME').live('pageshow', function(event)) {
// cache this page for later use (inside the AJAX function)
var $this = $(this);
// make an AJAX call to your PHP script
$.getJSON('http://www.WEBSITENAME.com/ServerFile.php', function (response) {
// create a variable to hold the parsed output from the server
var output = [];
// if the PHP script returned a success
if (response.status == 'success') …Run Code Online (Sandbox Code Playgroud)