i have loader in user panel waiting response user's mobile device. unfortunately i'm compeletly blank on how request mobile device, , update page content real time.
right problem have sending data view page controller function through ajax .... in controller function sending data ajax function other function in utility class , returning result ajax function.... , whenever receive response controller function starting loader/preloader/ajax spinner ... after sending variable android ... after android response comes want stop loader ... dont know how call ajax function , response controller
there can 2 ways acheive
1st either call directly javascript function android , grab value . 2nd or call javascript function controller , send value in ajax function ..dont know if possible ...
my js function
function openprompt() { var cancelled = true; var lock='lock'; $.modal.prompt('enter message :', function(value) { $.ajax({ type:"post", data:{value:value,lock:lock}, url:"/allsecure/api/lock/", success : function(data) { //start spinner }, error : function() { alert("error"); } }); }, function() { }); };
controller function
public function lock(){ if( $this->request->is('ajax') ) { $message = $this->request->data('value'); $lock = $this->request->data('lock'); $this->loadmodel('userinfo'); $userid = $this->auth->user('iduser'); $key = $this->userinfo->getkey($userid); $apikey = "1234567890"; $resp = allsecure::sendnotification($apikey, array($key), array('message' => $lock, 'tickertext' =>$message)); echo $resp; //after response starting loader } } function android(){ // here getting variable android $json = $this->request->data('json'); $data = json_decode($json, true); openprompt()//here want call javascript function , want send value of android javascript }
or there better approach ???
if want execute client javascript server can similar thing jsonp does. response json data wrap in javascript function executed in client.
Comments
Post a Comment