我正在制作 phonegap 应用程序,其中我使用 jquery ajax 将数据发送到服务器,作为响应,我正在发送消息。当我在 phonegap 上运行它时,我总是给出错误消息。我的代码
<!DOCTYPE HTML>
<html>
<head>
<title>-</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"> </script>
<script type="text/javascript" src="jquery-2.0.3.min.js"></script>
<script>
function validation2()
{
alert('validation');
alert("login");
var server_url ="http://dealsscanner.com/labourapp/login_check.php";
/* stop form from submitting normally */
//event.preventDefault();
/*clear result div*/
/* get some values from elements on the page: */
//var values = $(this).serialize();
var values = { A1984 : 1, A9873 : 5, A1674 : 2, A8724 : 1, A3574 : 3, A1165 : 5 }
/* Send the data using post and put the results in a div */
$.ajax({
type: "GET",
url: server_url,
cache: false,
data: values,
success: function(msg){
alert(msg);
},
error:function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(err.Message);
}
});
}
$(function() {
$.ajax({
url: "http://dealsscanner.com/labourapp/login_check.php",
dataType: 'jsonp',
jsonp: 'jsoncallback',
timeout: 15000,
success: function(data, status){
//handle your data
$('#response').html('There was no error loading the data.');
},
error: function(request, status, error) {
console.log("Error status " + status);
console.log("Error request status text: " + request.statusText);
console.log("Error request status: " + request.status);
console.log("Error request response text: " + request.responseText);
console.log("Error response header: " + request.getAllResponseHeaders());
console.log("Error error: " + error);
$('#response').html('There was an error loading the data.');
alert('There was an error loading the data');
}
});
});
</script>
</head>
<body>
<div id ="response"></div>
<form id="form">
<table>
<tr>
<th></th>
<th></th>
</tr>
<tr>
<td><h1> Login </h1></td>
</tr>
<tr>
<td> Enter email</td>
<td><input type="text" id ="email" name ="email" /> </td>
</tr>
<tr>
<td>Password</td>
<td><input type ="password" id ="pass" name ="pass"/></td>
</tr>
<tr>
<td colspan ="2"><input type="submit" id="submit" name ="submit" /></td>
</tr>
</table>
</body>
</form>
</html>
因为我的 php 文件只包含这个
<?php
echo "ok";
?>