2015-12-30 145 views
0

当我执行一个简单的Ajax请求我收到以下错误错误Ajax请求

TypeError: 'toString' called on an object that does not implement interface HTMLAnchorElement.

这是我的AJAX脚本

<script type="text/javascript"> 
    $(document).on("ready", function(){ 
     $("#tabla_persona table tr").click(function() { 
      var cod = $("#identificador",this); 
      alert(cod.html()); 

      var parametros={ 
       "cod":cod 
      }; 

      $.ajax({ 
       type: 'POST', 
       url: '<?php echo site_url("archivo/prueba"); ?>', 
       data: parametros, 
       success: function(resp) { 
        $("#tabla_usuario_individual").html(resp); 
       } 
      }); 


     }); 
    }); 
</script> 

这是我的控制器

public function prueba(){ 
    $this->load->view('datos_persona'); 

} 

和我简单的页面看到的结果

<a> 
Prueba 
    </a> 
+0

什么类型的元素是'#identificador'? – Barmar

+0

您正在传递一个jQuery对象('cod')作为数据'var parametros = {“cod”:cod};' – Andreas

+0

回答

0

尝试改变:

 var parametros={ 
      "cod":cod 
     }; 

到:

 var parametros={ 
      "cod":cod.html() 
     }; 
+0

然后这就是结果 – JulenMLejarza

+0

“NetworkError:500 Internal Server Error - http:// localhost/PROYDW3/index.php文件/档案馆/ prueba” – JulenMLejarza

0

只需要简单change.I认为下面的代码将工作。

public function prueba(){ 
    echo $this->load->view('datos_persona',true); 
}