• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ajax and Controller

#1
Staff speaks okay, next have a ajax and he calls the controller but it does not receive POST, see the codes below:

Ajax
Code:
function sendFile(file){
data = new FormData();
data.append("file", file);

$.ajax({
           data: data,
           type: "POST",
           url: '/painel/admin/upload/summernote',
           cache: false,
           contentType: false,
           processData: false,
           success: function(url){
               $('.summernote').summernote('editor.insertImage', url);
           }
       });
}

Controller
PHP Code:
public function summernote(){
 
   print_r($_REQUEST);
 
   die();


Route
PHP Code:
$route['upload/summernote'] = 'uploads/summernote'

Result of print_r
Array()

what I'm doing wrong to the controller does not receive the post of ajax ? Thank you
Reply

#2
url should be full and don't use print_r , just echo, for example :
Code:
               $.ajax({
                   type: "POST",
                   dataType: "text",
                   url: "<?php echo site_url('upload/summernote') ?>",

                   success: function(msg) {
                     console.log(msg)
                    }

               });
   

Code:
public function summernote(){
   echo 'hello';
}
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.