In Association with Amazon.in   Flipkart

Friday, August 30, 2019

Jquery and Ajax get post sample method functions

// =========  ****************  ================
// ============= to set add new qus: txt/img =========

function set_qbox(qt){
  if(qt === 'T') {
    document.getElementById('Tqbox').style.display = 'block';
    document.getElementById('Iqbox').style.display = 'none';
    document.getElementById('t1').value = 'T';
  } else {
    document.getElementById('Iqbox').style.display = 'block';
    document.getElementById('Tqbox').style.display = 'none';
    document.getElementById('t2').value = 'I';
  }
}

// ============= to get topics with subj_id ======

function get_stopics(subj){
$(".tcls").remove();
  $.get(window.site_burl+"jqfunctions/get_topics/",{subj_id:subj},function(response){
                   if(response){
                        $(".tcls").remove();
                        $("#topic").append(response);
                   }
                });
}

// ============= to get topics2 with subj_id =======

function get_stopics2(subj){
$(".tcls").remove();
  $.get(window.site_burl+"jqfunctions/get_topics/",{subj_id:subj},function(response){
                    if(response){
                        $(".tcls").remove();
                        $("#topic2").append(response);
                    }
                });
}

// ============= to update question =======

function updt_ques(qid, col, val){
  $.get(window.site_burl+"jqfunctions/updt_ques/",{qid:qid, col:col, val:val},function(response){
                    if(response){
                      //alert(response);
                    }
                });
}

// ************** to get batches with course_id*******************

function get_cbatches(subj){
$(".tcls").remove();
  $.get(window.site_burl+"jqfunctions/get_cbatches/",{subj_id:subj},function(response){
                   if(response){
                        $(".tcls").remove();
                        $("#batch").append(response);
                   }
                });
}

codeignator model sample method statements

Calling model user define ganesh funs:::-
****************************************
To load view page:
==================
$data='Array values';
$this->load->view('admin/users', $data);
----------------------------------

To redirect some page:
======================
           redirect(base_url().'admin/dashboard', refresh);
----------------------------------

To Fetch data:
======================
    $sql1="SELECT * FROM `users` WHERE md5(id) = '$id' AND status <> 'DONE';";
     $resp1=$this->user_model->run_query($sql1);
     if($resp1->num_rows()) {
      foreach ($resp1->result() as $row)
// print row data;
}
--------------------------

To insert data Row:
===================
            $this->user_model->insertRow('users', $data);

------------------------------

To update data Row:
=================
$this->user_model->updateRow('table_name', 'where_field', $where_value, $array_values);
-----------------------------

To Delete Data Row:
===============
$this->user_model->delete_id('table_name', 'where_field', $where_value, $array_values);

--------------------------------------
To Send Email Message:
=======================
$this->user_model->send_email_msg($fromemail, $toemail, $Subject, $emailmsg);

--------------------------------------

To Get Count:
=============
$data['tot_res']= $this->user_model->getValueQry("SELECT count(*) as val FROM `orders` WHERE status = 'Active'");
---------------------------------

To upload file:
===================
      // --------- for inserting Qfile
         foreach($_FILES as $name => $fileInfo) {
               if(!empty($_FILES[$name]['size'])){
              $filename=$_FILES[$name]['name'];
            $exp=explode('.', $filename);
            $ext=strtolower(end($exp));

                  if($name === 'photo') {
                    if($ext === 'jpeg' || $ext === 'jpg' || $ext === 'png'){

                      $newname=  time()."_".$filename;
                      $tmpname= $_FILES[$name]['tmp_name'];

                       if(move_uploaded_file($tmpname,"media/photos/".$newname)) {
                       $data['photo']=$newname;
                 //      $this->user_model->updateRow('tnm', 'trf_id', $trf_id, $ddoc);
                     }
                   }
                 }
}}
------------------------------------------

To Set Session Data:
====================
             $this->session->set_userdata('admin_data',$return);
-------------------------------

To get/print session value:
=============================
             $admin_id = $this->session->admin_data->id;
-------------------------------

To set onetime session message:
=================================
                 $this->session->set_flashdata("messagePr", '<div class="notification error closeable"><p><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Login Failed.. Please try again..!</p><a class="close" href="#"></a></div>');
-------------------------------------

To print one time session message:
=================================
echo $this->session->flashdata('messagePr');
--------------------------------------------

To unset session data:
======================
$this->session->unset_userdata('admin_data');
---------------------------------


Related Posts Plugin for WordPress, Blogger...