Welcome Guest, Not a member yet? Register   Sign In
Use action from controller to return data to AJAX or load views with content?
#2

[eluser]Fationably Late[/eluser]
You could do something like this:

Code:
public function delete_image($imageID = NULL,$ajax = NULL)
  {
    $result = Media::removeImage($imageID);
    if($ajax){
      echo json_encode($result);
      exit; // <- note the exit here!
    }
    return $result;
  
  }

and append a segment to the end of your url in the ajax call.
OR
You could pass an 'unknown' variable in the $_POST array of your ajax call and check for it there.

Code:
public function delete_image($imageID = NULL)
  {
    $result = Media::removeImage($imageID);
    if( array_key_exists($this->input->post('ajax')) ){ // or however you want to check for it
      echo json_encode($result);
      exit; // <- note the exit here!
    }
    return $result;
  
  }


Messages In This Thread
Use action from controller to return data to AJAX or load views with content? - by El Forum - 01-09-2013, 03:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB