<script type="text/javascript">
$(function(){
$('.update').click(function(){
$.ajax({
type: "POST",
url: "/reporting_results/mark_result",
data: "id="+$(this).attr("id")+"&check="+$(this).val()+"&user_id=<?=$user_id?>&product=<?=$this->uri->segment(3)?>",
});
return true
});
});
</script>
views:
42answers:
2
+6
A:
Because of a trailing comma, right before the end of your $.ajax options:
data: "id="+$(this).attr("id")+"&check="+$(this).val()+"&user_id=<?=$user_id?>&product=<?=$this->uri->segment(3)?>", <-- trailing comma, is why
karim79
2010-05-12 23:02:15
Bo! Good catch!
spender
2010-05-12 23:03:48
This drives me nuts on IE. Gets me all the time
webdestroya
2010-05-12 23:06:03
Brill, thanks!!!
Nathan Pitman
2010-05-13 07:31:21
A:
Inside the $.ajax brackets, the this context changes to the ajax action. Can you verify that this is pointing to the original element that initiated the click event? I've done stuff like this before, and I remember needing to prefetch variables before entering the $.ajax block.
$('.update').click(function() {
var id = $(this).attr('id');
var value = $(this).val();
var product = '<?=$this->uri->segment(3)?>';
$.ajax({
type: "POST",
url: "/reporting_results/mark_result",
data: "id="+id+"&check="+value+"&user_id=<?=$user_id?>&product="+product
});
});
In javascript, the this reference can be very tricky at times, since it refers to the current javascript contextual object.
Jarrett Meyer
2010-05-12 23:05:04