我做了一個審覈腳本,投票上下問題和答案。前一段時間,腳本工作,但當我回來再次開始在這個項目中編碼時,它不再工作了。通過郵政發送信息與阿賈克斯問題
腳本是這樣做的:當你點擊一個名爲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