當我執行一個簡單的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>
什麼類型的元素是'#identificador'? – Barmar
您正在傳遞一個jQuery對象('cod')作爲數據'var parametros = {「cod」:cod};' – Andreas