<script type="text/javascript" language='javascript'>
$('#view_comment').submit(function() {
alert("msg");
var sec={'post_id_for_view_comment' : $("#post_id_for_view_comment").val()}
$.ajax({
url: "<?php echo base_url().'index.php/'; ?>post_comment/get_all_comments",
type: 'POST',
data: sec,
success: function(msg) {
alert(msg);
}
});
});
</script>
public function get_all_comments()
{
echo 'OK';
}
Ajax 호출이 제어기에 제공되지
<form id="view_comment" method="post" >
<input type="hidden" name="post_id_for_view_comment" id="post_id_for_view_comment" value="<?php echo $row->post_id; ?>" />
<input type="submit" id="post_button" value="View Comments" />
</form>
컨트롤러에 주어지지 않는다. 나는 한 페이지에 하나 이상의 양식을 가지고있다.
var sec 세미콜론을 놓치거나 잘못 입력 했습니까? –
세미콜론을 넣을 위치는 어디입니까? –
'var id = $ ("# post_id_for_view_comment") .Val();' '/////////////// 'data : {post_id_for_view_comment : id}' –