我试图将使用jquery的表中的变量thecode
传递给名为getComments()
的函数。我的代码如下。首先,我有我的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()
函数?
答案 0 :(得分:1)
import numpy as np
def inplace_process(a, rows, C, N):
a[rows, :] = float(C*N)
C = 4
N = 128
x = np.zeros((C, N))
# process a specific set of rows
inplace_process(x, (0, 1, 3), 3, N)
# independently process an inner row
inplace_process(x, [2], 1, N)
时,不需要在网址中写入$.post
参数(action = post)。GET
(php
)。$_POST['comment']
时,ajax
不应使用function
或致电php
定义之后。function
文件中使用ajax
必须print
或echo
数据时,
发布结果。