2014-05-17 4 views
0

나는 아약스 기능을 가질 수 어떤 working.Tried하지는 CodeIgniter의 아약스 내가

$('a[name=deleteButton]').on('click', function() { 
    arr=[]; 
    var arr = $("input[name='post[]']:checked").map(function() { 
      return this.value; 
      }).get(); 
      var content = $(this).parents('tr').find('.key').html(); 
      alert(content); 
}); 

function makeAjaxCall(){ 
    $.ajax({ 
     type: "post", 
     url: "http://localhost/partner/app/UserController/verifyUser", 
     cache: false,    
     data: {id : content}, 
     success: function(data){       
       alert('hi'); 
     }, 
     error: function(td){       
      alert(td.responseText); 
     } 
}); 
} 

컨트롤러는 뷰가

<tr> 
           <td><input type='checkbox' name='post[]' value="<?php echo ++$i; ?>"></td> 
           <td><?php echo date('d-M-Y', strtotime($row['connct_CreationTime']));?></td> 
           <td><?php echo $row['connct_serviceName'];?></td> 
           <td><?php echo $row['connct_websiteUrl'];?></td> 
           <td class="key"><?php echo $row['connct_passKey'];?></td> 
           <td><?php echo $row['responseURL'];?></td> 
           <td><a name="deleteButton" href=""><i class="icon-remove text-danger"></i></a></td> 
           <!-- <td align='center' width='30'><a data-toggle='modal' href='#' ><i class='icon-remove text-danger'></i></a></td> --> 
          </tr> 

VAR 내용이 경고지고있다

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 

class UserController extends CI_Controller { 

    public function verifyUser() { 

     $status = array("STATUS"=>"false"); 

     echo json_encode ($status) ;  
    } 
} 

입니다. 그러나 네트워크 탭에서 ajax POST를 보여주는 것은 취소됩니다. 이 오류를 working.Also되지 않는 이유는 모두가 내가 할 수있는 시도,하지만 날

+0

같이해야한다 ???? –

+0

@rajeshkakawat 무엇입니까? – user3637105

+0

이것 좀 봐 http://ellislab.com/codeigniter/user-guide/libraries/security.html –

답변

0

가능한 해결 방법을 해결책을

http://localhost/partner/app/UserController/verifyUser 사용이를 찾는 데 도움이 working.Please하지 , td.responseText가 비어 있습니다 url이 맞는지 아닌지를 확인하고 어떤 결과가 나오는지 브라우저에서 직접 확인하십시오. csrf_protection이 활성화되어

원하는 출력 코드를 내 관점에서

EIDTED

오고하거나하지 않은 경우이

$('a[name=deleteButton]').on('click', function() { 
     arr=[]; 
     var arr = $("input[name='post[]']:checked").map(function() { 
       return this.value; 
       }).get(); 
       var content = $(this).parents('tr').find('.key').html(); 
       makeAjaxCall(content); 
      return false; 
    }); 

    function makeAjaxCall(content){ 
     $.ajax({ 
      type: "post", 
      url: "http://localhost/partner/app/UserController/verifyUser", 
      cache: false,    
      data: {id : content}, 
      success: function(data){       
        alert('hi'); 
      }, 
      error: function(td){       
       alert(td.responseText); 
      } 
    }); 
    } 
+0

예 이 URL을 goto로 올 때. – user3637105

+0

아약스 함수에서 경고하는 내용 변수, 당신이 무엇을 얻고 있는지 말해 보라 ????? –

+0

빈 경고를 받고있는 Im yyaar :( – user3637105