0
我試圖將表中使用jquery的變量thecode
轉換爲名爲getComments()
的函數。我的代碼如下。首先,我有我的jQuery腳本是這樣的:將表中的值傳遞給使用jquery的函數
$(document).ready(function(){
$("#comment_process").click(function(){
if($("#comment_text").val() != ""){
$('.post_loader').show();
$.post("comments_business.php?action=post", {
comment: $("#comment_text").val()
}, function(data) {
$(".comments").hide().html(data).fadeIn('slow');
$("#comment_text").val("");
$('.post_loader').hide();
});
}
});
});
接下來我有HTML和PHP下面的腳本:
<!--- more code at the top---->
<?php $auto = $profile_data_business['business_code']; ?>
<table>
<textarea rows="3" id="comment_text" placeholder="share an update."></textarea>
<input type="" id="comment_code" name="thecode" value="<?php echo $auto; ?>" />
<input type="button" id="comment_process" />
</table>
<div class="comments"><?php include_once("comments_business.php");?> </div>
命名爲comments_business.php
該頁面包含一個函數如下:
<?php
function getComments(){
$session_user_id = $_SESSION['user_id'];
$comments = "";
// can't get variable $thisemail
$thisemail = mysql_real_escape_string($_POST['thecode']);
$sql = mysql_query("SELECT * FROM comments_business WHERE (`flag`=0 and `user`='$thisemail' and `comments_id` NOT IN (SELECT `comments_id` FROM `hide_comment_business` where `user`='$session_user_id')) ORDER BY comment_date DESC LIMIT 40") or die (mysql_error());
//more code here
return $comments;
}
?>
任何想法如何更改我的jQuery代碼,以便我將能夠將$thisemail
變量成功地通過getComments()
func重刑?
問題是,您如何/在哪裏調用'getComments()'函數並啓動會話? –
是會話已經開始 – 33528
你也沒有'