So I am getting better at using phonegap but am still trying to fully add codeigniter as the backend. I have been able to .load in jquery something from a controller of my CI to my phonegap android app but can't seem to submit anything TO the server properly. Do you need a rest server to communicate with CI from phonegap? I was planning on using ajax post to info to CI but so far unable to get it to work. I'd really appreciate it someone can help me over this hurdle. Thanks
Controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
//$this->load->view('welcome_message');
$data['query']=$this->site_model->get_last_ten_articles();
$this->load->view('partial1',$data);
}
public function addarticle(){
$headline=$this->input->post('headline');
$article=$this->input->post('article');
$this->site_model->insert_entry($headline,$article);
}
}
Javascript(on phonegap device)
function add_article(){
$.ajax({
type: 'POST',
url: 'http://testlab.site40.net/droiddev/welcome/addarticle/',
data: {"headline": "test headline","article": "test article"}
error: function(){alert('fail');},
success: function(data){
alert('article added');
},
dataType: "json"
});
}