ciao sto sviluppando un'app per Android (uso phonegap, html5 e javascript) che si collegano a un database mysql remoto. ho creato un servizio web RESTful (codeigniter) per accedere al database mysql, quindi l'app Android può chiamare il servizio web per ottenere o inviare dati al db, usando XML o JSON come formato dei dati.ottiene i dati dal server con jquery ajax in Android PhoneGap
Nel browser Web utilizzando jquery ajax sto ottenendo con successo il risultato ma nell'app Android non ricevo la risposta.
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);
}
});
nel server:
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);
}
Non vedo alcun codice Android qui ...? – Tushar
ups mi dispiace usare phonegap, html5 e javascript per lo sviluppo di app android – Aditya