Can';t从我的php脚本中调用Ajax函数,使用live table it
我正在做一个使用实时表编辑风格的项目(工作非常完美),但试图在其中一列(最后一列)中包含twitter风格的follow和unfollow。php工作得很好,但我在将数据返回到ajax以发布到另一个php脚本时遇到了问题 下面显示了脚本的主要部分(php和ajax)。我在重要的兴趣领域中加入了一条php评论Can';t从我的php脚本中调用Ajax函数,使用live table it,php,mysql,ajax,jquery,Php,Mysql,Ajax,Jquery,我正在做一个使用实时表编辑风格的项目(工作非常完美),但试图在其中一列(最后一列)中包含twitter风格的follow和unfollow。php工作得很好,但我在将数据返回到ajax以发布到另一个php脚本时遇到了问题 下面显示了脚本的主要部分(php和ajax)。我在重要的兴趣领域中加入了一条php评论 <?php $query_pag_data = "SELECT * FROM applicant_result WHERE year='$year' AND class='$cl
<?php $query_pag_data = "SELECT * FROM applicant_result WHERE year='$year' AND
class='$class' ORDER by candidate_no "; $uid=strip_tags($id);
$result_pag_data = mysql_query($query_pag_data) or die('MySql Error' . mysql_error());
$finaldata = "";
$tablehead= '';
$tablehead= "<tr>
<th class='data'>#</th>
<th class='data'>Applicant ID</th>
<th class='data'>Year</th>
<th class='data'>Class</th>
<th class='data'>$subject_1</th>
<th class='data'>$subject_2</th>
<th class='data'>$subject_3</th>
<th class='data'>$subject_4</th>
<th class='data'>$subject_5</th>
<th class='data'>Total</th>
<th class='data'>Status</th>
<th class='data'>Interview</th>
</tr>";
while($row = mysql_fetch_array($result_pag_data)) {
$id=htmlentities($row['candidate_no']);
$subject_1=htmlentities($row['subject_1']);
$subject_2=htmlentities($row['subject_2']);
$subject_3=htmlentities($row['subject_3']);
$subject_4=htmlentities($row['subject_4']);
$subject_5=htmlentities($row['subject_5']);
$total=htmlentities($row['total']);
$status=htmlentities($row['interview']);
$uid= strip_tags($row['candidate_no']);
/* HELLO FORUMITES, THIS IS THE MAJOR AREA OF FOCUS HERE */
if($status!=0){$button="
<span id='loading<?php echo $uid; ?>'></span>
<span class='button following' id='following<?php echo $uid; ?>' `onClick='follow_or_unfollow(<?php echo $uid; ?>,'following');'>Following</span>`
<span style='display:none;' class='button follow' id='follow<?php
echo $uid; ?>' onClick='follow_or_unfollow(<?php echo $uid; ?>,'follow');'>Follow</span>
";}
else{
$button="
<span id='loading<?php echo $uid; ?>'></span>
<span class='button follow' id='follow<?php echo $uid; ?>'
onClick='follow_or_unfollow(<?php echo $uid; ?>,'follow');'>Follow</span>
<span class='button following' style='display:none;'`id='following<?php echo $uid; ?>' onClick='follow_or_unfollow(<?php echo $uid;` ?>,'following');'>Following</span>
";}
$tabledata.="<tr id='$id' class='edit_tr'>
<td class='edit_td' ><span class='text'>$counter</span></td>
<td class='edit_td' ><span class='text'>$id</span></td>
<td class='edit_td' ><span class='text'>$year</span>
<input type='hidden' value='$year' class='editbox' id='six_input_$id' /></td>
<td class='edit_td' ><span class='text'>$class</span>
<input type='hidden' value='$class' class='tbox' id='seven_input_$id' /></td>
<td class='edit_td' >
<span id='one_$id' class='text'>$subject_1</span>
<input type='text' value='$subject_1' class='editbox' id='one_input_$id' /></td>
<td class='edit_td' ><span id='two_$id' class='text'>$subject_2</span>
<input type='text' value='$subject_2' class='editbox' id='two_input_$id'/></td>
<td class='edit_td' ><span id='three_$id' class='text'>$subject_3 </span>
<input type='text' value='$subject_3' class='editbox' id='three_input_$id'/></td>
<td class='edit_td' ><span id='four_$id' class='text'>$subject_4</span>
<input type='text' value='$subject_4' class='editbox' id='four_input_$id' /></td>
<td class='edit_td' ><span id='five_$id' class='text'>$subject_5</span>
<input type='text' value='$subject_5' class='editbox' id='five_input_$id' /></td>
<td class='edit_td' ><span class='text'>$total</span></td>
<td class='edit_td' ><span class='text'>$status</span></td>
<td>$button </td>
</tr>";
$counter++;
}
$finaldata = "<table width='100%'>".$tablehead." ".$tabledata. "</table>";
echo $finaldata;
尝试将ajax类型更改为GET类型:“GET”,
另外,您是如何在php的另一端接收全局消息的
您是否使用了GET
或POST
?
以及什么“不起作用”?我很感谢你分享你的代码,但是如果能解释一下你期望它做什么和它实际做什么就好了。在php的前几行中,你指的是$class、$year和$id。$id可能应该是$u POST['id']。我看不出$class或$year是在哪里定义的。REFUGNIC ETERNIUM:当我单击follow按钮时,ajax没有做出一般响应:上面的php脚本包含在另一个php脚本中,即(include'superscript.php';),所有变量都是从该脚本定义的。主要问题是如何通过ajax将onclick函数数据检索到follow_或unfollow.phpRefugnic Eternium链接:当我单击follow按钮时,ajax不会做出一般响应:上面的php脚本包含在另一个php脚本中,即(include'overscript.php'),所有变量都是从该脚本定义的。主要问题是如何通过ajax将onclick函数数据检索到follow\u或unfollow.php FrancisMarfo尝试获取,但在@ioums中无效:这些变量是c
<script type="text/javascript">
$(document).ready(function() {
$('.following').hover(function() {
$(this).text('Unfollow');
}, function() {
$(this).text("Following");
});
});
function follow_or_unfollow(id, action) {
var dataString = "id=" + id;
$.ajax({
type: "POST",
url: "follow_or_unfollow.php",
data: dataString,
beforeSend: function() {
if (action == "following") {
$("#following" + id).hide();
$("#loading" + id).html('<img src="loading.gif" align="absmiddle" alt="Loading...">');
}
else if (action == "follow") {
$("#follow" + id).hide();
$("#loading" + id).html('<img src="loading.gif" align="absmiddle" alt="Loading...">');
}
},
success: function(response) {
if (action == "following") {
$("#loading" + id).html('');
$("#follow" + id).show();
}
else if (action == "follow") {
$("#loading" + id).html('');
$("#following" + id).show();
}
}
});
}
</script>