Javascript.RU

Создать новую тему Ответ
 
Опции темы Искать в теме
  #1 (permalink)  
Старый 21.08.2011, 13:19
top top вне форума
Интересующийся
Отправить личное сообщение для top Посмотреть профиль Найти все сообщения от top
 
Регистрация: 12.08.2011
Сообщений: 15

google Chrome не хочет активировать функцию, а другие активируют
Здравствуйте, помогите пожалуйста с проблемой.
id_vote и ip определяются заранее и всё с ними работает, после определения переменных вызывается status_vote
Вот js код(там, вроде, всё правильно):
function status_vote(id_vote, ip){
	$.ajax({
		type: "POST",
		url: "php/voter.php",
		data: {
			action : "status_vote",
			id_vote : id_vote,
			ip : ip
		},
		cache: false,
		dataType: "json",
		success: function(result){
			$("#block_vote").html(result.form);
			$("#table_opros").fadeIn("slow");
		}
	});
}

function result_vote(id_vote, ip){
	$.ajax({
		type: "POST",
		url: "php/voter.php",
		data: {
			action : "status_vote",
			id_vote : id_vote,
			ip : ip,
			result_vote : "result"
			},
		dataType: "json",
		success: function (result){
				$("#table_opros").fadeOut("slow", function(){
					$("#block_vote").html(result.form);
					$("#table_opros").fadeIn("slow");
				});
		}
	});
}
	
function update_vote(id_vote, ip){
	var opr = $(":radio[name=opr]").filter(":checked").val();
	if ( $(":radio[name=opr]").filter(":checked").size() == 1){
		$.ajax({
			type: "POST",
			url: "php/voter.php",
			data: {
				action : "update_vote",
				id_vote : id_vote,
				ip : ip,
				opr : opr
				},
			dataType: "json",
			success: function (result){
				$("#table_opros").fadeOut("slow", function(){
					$("#block_vote").html(result.text);
					$("#table_opros").fadeIn("slow");
				});
			}
		});
	} else alert("Не выбран ответ");
	
}

а вот php-код(И в итоге при нажатии кнопки(в 44 и 51 строчках php-кода) ничего не вызывается в Chrome, а в опере и мозиле всё работает):
include "db_right.php";
	
	mysql_connect($way_db, $login_db, $password_db);
	mysql_select_db($point_db);
	mysql_query("SET NAMES 'utf8'");
	//header("Cache-Control: no-cache, must-revalidate");
	//header("Pragma: no-cache");
	header("Content-Type: text/javascript; charset=utf-8");
	
	if( isset($_POST['action']) ){
		switch ($_POST['action']){
			case "status_vote" : Status_vote(); break;
			case "update_vote" : Update_vote(); break;
			default : exit();
		}
	}
	
	function Status_vote(){
		$ip = $_POST['ip'];
		$number_vote = $_POST['id_vote'];
		$res = array();
		$sqlip = mysql_query("SELECT * FROM `vote_ip` WHERE ( (`id_vote` = '$number_vote') and (`ip` = '$ip') )");
		if (mysql_num_rows($sqlip) == 0) $res['ip'] = "no"; else $res['action'] = "yes";
		$res['number_vote'] = $number_vote;
		
		$sql = mysql_query("SELECT * FROM `vote` WHERE `id` = '$number_vote'");
		$result = mysql_fetch_assoc($sql);
		$question = $result['question'];
		$id = $result['id'];
		$vote_panel = file_get_contents("../template/opros.tpl");
		$vote_panel = str_replace("{question}", $question, $vote_panel);
		$vote_panel = str_replace("{id}", $id, $vote_panel);
		if ( (!isset($_POST['result_vote'])) and (mysql_num_rows($sqlip) == 0) ){
			$all_answer = "";
			for ($i=1; ; $i++){
				$answer = $result['answer_'. $i .''];
				if ($answer == "") break;
				$vote_answer = file_get_contents("../template/answer_in_vote.tpl");
				$all_answer .= str_replace("{answer}", $answer, $vote_answer);
			}
			$button =  "<tr>
							<td>
								<p style=\"margin:5px 0px 0px 2px;\" >
									<input
										style=\"width:85px; font-size:12px; color: #F00;\"
										type=\"button\"
										name=\"update_vote\"
										value=\"Голосовать\"
										onclick=\"update_vote(". $number_vote .",'". $ip ."');\"
									/>
									<input
										style=\"width:85px; font-size:12px; color: #F00;\"
										id=\"result_vote\"
										type=\"button\"
										name=\"result_vote\"
										value=\"Результаты\"
										onclick=\"result_vote(". $number_vote .",'". $ip ."');\"
									/>
								</p>
							</td>
						</tr>";
			$all_voters = "";
			$vote_panel = str_replace("{all_voters}", $all_voters, $vote_panel);
			$vote_panel = str_replace("{button}", $button, $vote_panel);
			$vote_panel = str_replace("{answer_all}", $all_answer, $vote_panel);
		} else {
			$all_answer = "";
			$all = 0;
			for ($i=1; ; $i++){
				$answer = $result['answer_'. $i .''];
				$result_vote = $result['result_'. $i .''];
				$result_vote = intval($result_vote);
				$all = $all + $result_vote;
				if (($answer == "") and ($result_vote == 0)) break;
			}
			for ($i=1; ; $i++){
				$answer = $result['answer_'. $i .''];
				$result_vote = $result['result_'. $i .''];
				$result_vote_n = intval($result_vote);
				if ($result_vote_n !== 0) $procent = ($result_vote_n / $all) * 100; else $procent = 0;
				$procent = round($procent, 2);
				if (($answer == "") and ($result_vote == 0)) break;
				$vote_answer = file_get_contents("../template/result_in_vote.tpl");
				$vote_answer = str_replace("{answer}", $answer, $vote_answer);
				$vote_answer = str_replace("{procent}", $procent, $vote_answer);
				$all_answer .= str_replace("{result}", $result_vote, $vote_answer);
			}
			$button = "";
			$all_voters = "<tr><td><p id=\"all_voters\">Всего проголосовало: <strong>". $all ."</strong></p></td></tr>";
			$vote_panel = str_replace("{all_voters}", $all_voters, $vote_panel);
			$vote_panel = str_replace("{button}", $button, $vote_panel);
			$vote_panel = str_replace("{answer_all}", $all_answer, $vote_panel);
		}
		
		$res['form'] = $vote_panel;
		
		echo json_encode($res);
	}
	
	function Update_vote(){
		$opr = $_POST['opr'];
		$id = $_POST['id_vote'];
		$res = array();
		$sql = mysql_query("SELECT * FROM `vote` WHERE id = '$id'");
		$result = mysql_fetch_assoc($sql);
		for ($i=1; ; $i++){
			$answer = $result['answer_'. $i .''];
			if ($answer == $opr){
				$n = $i;
				break;
			}
		}
		$number_vote = $id;
		$ip = $_POST['ip'];
		mysql_query("INSERT INTO `vote_ip` (`id_vote`, `ip`) VALUES ('$number_vote', '$ip')");
		mysql_query("UPDATE vote SET result_". $n ." = result_". $n ." + 1 WHERE `id` = '$id'");
		
			$sql = mysql_query("SELECT * FROM `vote` WHERE `id` = '$number_vote'");
			$result = mysql_fetch_assoc($sql);
			$question = $result['question'];
			$id = $result['id'];
			$vote_panel = file_get_contents("../template/opros.tpl");
			$vote_panel = str_replace("{question}", $question, $vote_panel);
			$vote_panel = str_replace("{id}", $id, $vote_panel);
			$all_answer = "";
			$all = 0;
			for ($i=1; ; $i++){
				$answer = $result['answer_'. $i .''];
				$result_vote = $result['result_'. $i .''];
				$result_vote = intval($result_vote);
				$all = $all + $result_vote;
				if (($answer == "") and ($result_vote == 0)) break;
			}
			for ($i=1; ; $i++){
				$answer = $result['answer_'. $i .''];
				$result_vote = $result['result_'. $i .''];
				$result_vote_n = intval($result_vote);
				if ($result_vote_n !== 0) $procent = ($result_vote_n / $all) * 100; else $procent = 0;
				$procent = round($procent, 2);
				if (($answer == "") and ($result_vote == 0)) break;
				$vote_answer = file_get_contents("../template/result_in_vote.tpl");
				$vote_answer = str_replace("{answer}", $answer, $vote_answer);
				$vote_answer = str_replace("{procent}", $procent, $vote_answer);
				$all_answer .= str_replace("{result}", $result_vote, $vote_answer);
			}
			$button = "";
			$all_voters = "<tr><td><p id=\"all_voters\">Всего проголосовало: <strong>". $all ."</strong></p></td></tr>";
			$vote_panel = str_replace("{all_voters}", $all_voters, $vote_panel);
			$vote_panel = str_replace("{button}", $button, $vote_panel);
			$vote_panel = str_replace("{answer_all}", $all_answer, $vote_panel);
			
		$res['text'] = $vote_panel;
		
		echo json_encode($res);
	}
Ответить с цитированием
Ответ



Опции темы Искать в теме
Искать в теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Google Chrome: GET http://url/url undefined (undefined) Kirumbik Opera, Safari и др. 0 07.05.2011 23:26
Неккоректное отображение jquery меню в Google Chrome и Opera Galyanov Opera, Safari и др. 6 25.01.2011 00:26
Неправильная высота блоков в Google chrome Karpo Opera, Safari и др. 7 03.11.2010 11:43
Google Chrome перерисовка страницы во время выполнения скрипта Dekart Javascript под браузер 0 08.06.2010 08:35
Google Chrome Андрей Параничев Opera, Safari и др. 42 02.08.2009 14:23