嗨,我正在開發一個應用程序爲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