嗨,我正在开发一个应用程序为Android(使用phonegap,html5和JavaScript),它连接到远程mysql数据库。 我创建了一个RESTful(codeigniter)Web服务来访问mysql数据库,然后Android应用程序可以调用Web服务来获取或发布数据到数据库,使用XML或JSON作为数据格式。从android服务器获取数据与jquery阿贾克斯phonegap
在使用jquery ajax的web浏览器中,我成功地获得了结果,但在android应用程序中没有得到响应。
jQuery.ajax({
url : 'http://10.10.1.129/index.php/apiauth/auth/?'+jQuery("#form-login").serialize(),
async :true,
cache :false,
/*crossDomain : true,*/
dataType : 'jsonp',
success:function(data){
alert(data);
}
});
服务器:
require APPPATH.'/libraries/REST_Controller.php';
class Apiauth extends REST_Controller
{
function auth_get()
{
$this->load->model('mauth');
$username = $this->input->get('username') ? $this->input->get('username') : $this->get('username');
$password = $this->input->get('password') ? $this->input->get('password') : $this->get('password');
$auth = $this->mauth->getUserLogin('*',$username,$password);
$row = $auth->row();
if($row){
$data = array('username'=>$row->username, 'fullname'=>$row->fullname,'error'=>FALSE);
}else{
$data = array('error'=>true);
}
$this->response($data, 200);
}
我在这里看不到任何Android代码......? – Tushar 2013-03-28 07:18:05
ups对不起,我使用phonegap,html5和javascript开发android应用程序 – Aditya 2013-03-28 07:22:20