看到這樣的HTML標記:查找其中代碼失敗
<input value="9961" name="c_id" id="c_id" type="hidden">
<input name="user_id" id="user_id" value="1" type="hidden">
<textarea id="comments" name="comments" style="width: 310px; resize: none; height: 75px"></textarea>
然後我寫jQuery的驗證碼通過。員額發送這樣的數據:
$("#dialog-form").dialog({
autoOpen: false,
height: 220,
width: 350,
resizable: false,
modal: true,
buttons: {
"Ok": function() {
if ($('#comments').val() != '') {
$.post("<?php echo site_url('wall/comment') ?>", {
value: $("#comments").val(),
user_id: $('#user_id').val(),
c_id: $("#c_id").val(),
is_post: true
});
$(this).dialog("close");
$(location).attr('href', "<?php echo site_url(); ?>");
}
},
"Cancelar": function() {
$(this).dialog("close");
}
},
close: function() {
$("#comments").val("");
}
});
但出於某種原因不能正常工作但因爲我使用.post
方法,我無法找到它失敗的位置,這意味着如果是jQuery或者它是服務器端部分。
編輯 這是PHP代碼中獲取數據和運行,基本上是一個INSERT查詢:
public function comment() {
role_or_die('wall', 'comment', site_url(), lang('wall:no_permissions'));
$message = $this->input->post('value', TRUE);
$post_id = $this->input->post('c_id', TRUE);
$user_id = $this->input->post('user_id', TRUE);
$this->load->library('user_agent');
$device = "";
if ($this->agent->is_browser()) {
$device = $this->agent->browser();
}
if ($this->agent->is_mobile()) {
$device = $this->agent->mobile();
}
if ($this->wall_comment_m->insert(array('friend_id' => $user_id, 'message' => $message, 'post_id' => $post_id, 'device' => $device))) {
$this->session->set_flashdata('success', lang('message:comment_add_success'));
} else {
$this->session->set_flashdata('error', lang('message:comment_add_error'));
}
}
我看不到,如果生成的SQL是錯誤的,或者數據ISN」由於location.href而設置在服務器端。
我怎麼能找到它失敗的地方?任何方法或其他工具來完成這件事?
在PHP中,使用'var_dump($ _ POST);'。這會告訴你通過POST傳遞給PHP腳本的內容。 – Travesty3
什麼「不工作」。代碼目前做了什麼? –
僅供參考,它是HTML代碼,並且您的