$('#loginForm').submit(function() {
$("#loginsubmit",this).attr("disabled","disabled");
var u = $("#loginemail", this).val();
var p = $("#loginpassword", this).val();
var postTo = 'http://www.example.com/login.php';
if(u != '' && p!= '') {
//navigator.notification.alert("not empty"+u, function() {});
var apiurl = "http://www.mapyi.com/api/mapyi/client.php?"+"action=verlogin&pass="+p+"&email="+u;
$.ajax({
url: apiurl,
dataType: 'jsonp',
jsonp: 'jsoncallback',
timeout: 5000,
success: function(data){
navigator.notification.alert("not empty"+data);
},
error: function(msg){
navigator.notification.alert("ERROR"+msg);
}
});
} /* end if u and p */
//hide();
//$('#homepage').show();
return false;
});
我在 phonegap.xml 添加了访问权限,还为 android 添加了更新 manifest.xml。php 响应在 json 中:
/* PHP CODE SErver side */
/* output in necessary format JSON */
header('Content-type: application/json');
echo json_encode(array('posts'=>$ret));
我不知道我错过了什么,它总是显示带有输出 ERROR [object] [object] 的 ERROR 对话框
**已解决我自己解决了,我没有在 php 服务中添加标头信息。header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']); header('Cache-Control: no-cache, must-revalidate'); 感谢 CODER DECODER ENCODER 抽出宝贵时间**