Welcome Guest, Not a member yet? Register   Sign In
send the data received from a view with ajax to model for to do a comparisson
#1

[eluser]masentinel900[/eluser]
Now I made a script that send me a data from a view to CI controller. all goes ok. But I was thinking how can I do for to compare a record of a specific row with the data received from the view.

I have this:

[Jquery]

Code:
$(document).ready(function() {
var value = $("#in-val-fun");
$("#button-create-gen").click(function(){
  if($('input[name="in-val-fun"]:checked').length !== 0)
  $.post("modal", {'value' : value.val()},
  function(data){
   $.fancybox({
    openEffect    : 'fade',
    closeMethod   : 'zoomOut',
    href          : 'modal',
    type          : 'ajax',
    content       :  data,
    helpers    : {
    title : { type : 'inside' },
                        },
    });
   },"json");
  else
  {
  alert('Please check any option');
  }
});
});

[CI Controller]

Code:
function index()
{
  if($this->session->userdata('logged_in'))
  {
   $data = trim($this->input->post('value'));
   echo json_encode($data . "Diego");  
   $session_data = $this->session->userdata('logged_in');    
   $query = $this->db->get_where('funciones',array('idfuncion' => $data));
   $datas = $query->row_array();
   if($query->num_rows() > 0)
   {
    $this->load->view('Modal', $datas);
   }
   else
   {
    redirect('functionPortal', 'refresh');
   }
  }
    }

Basically all this is because I need to show all the info of a task in a new window. In my main view I have a table with the name of the tasks and a radio input, if I want to know in what consisting the task I just check the radio and send the form. then the app will show me a fancybox window with the description of the task, who will should to do it.

For that I get the value of the radio input that is the id of the task and send it to controller for may compare with the DB and like this may to send again the new data to view that will open the fancy window.

Thanks by your help!!




Theme © iAndrew 2016 - Forum software by © MyBB