我做了一个审核脚本,投票上下问题和答案。前一段时间,脚本工作,但当我回来再次开始在这个项目中编码时,它不再工作了。通过邮政发送信息与阿贾克斯问题
脚本是这样做的:当你点击一个名为vote的投票,或者投票1的链接时,它会询问它是否启动。如果它已启动,则会加载url:“mod_up_vote.php”,通过邮寄发送关于您投票的问题的一些信息。还可以。但是不是现在。它不会加载该页面,因为我正在打印并在数据库中插入$ _POST变量,并且没有任何内容。
你认为在这里有什么错误?谢谢。
$(document).ready(function()
{
$(document).delegate('.vote, .vote1', '.vote2', 'click', function()
{
var id = $(this).attr("id");
var name = $(this).attr("name");
var dataString = 'id='+ id ;
var parent = $(this);
if(name=='mod_up')
{
$(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">');
$.ajax({
type: "POST",
url: "mod_up_vote.php",
dataType: "xml",
data: dataString,
cache: false,
success: function(xml)
{
//$("#mod-pregunta").html(html);
//$("#mod-respuesta").html(html);
//parent.html(html);
$(xml).find('pregunta').each(function(){
var id = $(this).attr('id');
var pregunta = $(this).find('preguntadato').text();
var respuesta = $(this).find('respuestadato').text();
var votoup = $(this).find('votoup').text();
var votodown = $(this).find('votodown').text();
var id_pregunta = $(this).find('id_pregunta').text();
var id_respuesta = $(this).find('id_respuesta').text();
$("#mod-pregunta").html(pregunta);
$("#mod-respuesta").html(respuesta);
//$(".vote").attr('id', $(this).find('id_pregunta').text());
$(".vote1").html("<a href=\"modera\" title=\""+ id_pregunta + "-"+ id_respuesta + "-1\" class=\"vote1\" id=\""+ id_pregunta + "-"+ id_respuesta + "-1\" name=\"mod_up\">Aceptar</a>");
$(".vote2").html("<a href=\"modera\" title=\""+ id_pregunta + "-"+ id_respuesta + "-2\" class=\"vote2\" id=\""+ id_pregunta + "-"+ id_respuesta + "-2\" name=\"mod_up\">Rechazar</a>");
//$("span", this).html("(ID = '<b>" + this.id + "</b>')");
});
} });
}
return false;
});
你确定它没有加载页面?你有没有检查过PHP页面没有错误? – 2012-03-16 22:45:21
在网址:“mod_up_vote.php”,我插入数据库的测试值,它不保存任何东西。 – 2012-03-16 22:46:15
但你确定它插入正确吗?听起来这可能是“mod_up_vote.php”的问题。 – 2012-03-16 22:57:27