Zrobiłem sobie na stronie skrzynkę, żeby użytkownicy mogli kontaktować się między sobą.
Niektóre wiadomości nie chcą się otwierać. Otworzyłem konsolę i po kliknięciu w taką nieaktywną wiadomość wyskakuje "Uncaught SyntaxError: Unexpected token ILLEGAL".
Czytałem, że to może być wina js, ale przyczyn może być wiele. Wiadomości nie zawierały żadnych szczególnych znaków to były testowe wiadomości w stylu "asdasd"
Mam sporo kodu, jednak wrzucę, gdyby ktoś miał ochotę na to zerknąć.
<div id="messagebox">
<?php
$messages = mysql_query("SELECT * FROM msg WHERE receiver = '".$nick['nick']."' ORDER BY id DESC "); $x = $allmessages['id'];
$m = $allmessages['message'];
$n = $nickfetch['sender'];
$s = $allmessages['seen'];
echo "<button class='my-button' id='".$x."' onClick=\"openmsg('$m','$n');seenupdate('$x')\">"; echo "<div class='left'>" . substr($allmessages['message'],0,40) . " " . "..." . "</div>"; echo "<div class='right'>" . $allmessages['date'] . " " . " " . " "; echo '<div class="nicklink"><a href="user.php?user=' . $allmessages['sender'] . '">' . $allmessages['sender'] .'</div>';
echo "</button>". "<br /> <br />"; if ($s == "no"){
$(document.getElementById(".$x.")).css('background-color', '#adff2f');
$(document.getElementById(".$x.")).css('color', 'black');
</script>
";
}
}
?>
</div>
<script>
function openmsg(m,n) {
$(document).ready(function(){
document.getElementById("messagebox").innerHTML = "<div class='mes'>Wiadomość:<br />" + m + "<br /><br /><a href='mailbox.php' id='wstecz'><button>wstecz</button></a>" + "<a href='respond.php?user=" + n + "' id='wstecz'><button>odpowiedz</button></a></div>";
});
}
</script>
<script>
function seenupdate(x) {
$.ajax({
type : "POST",
url : "messageseenupdate.php",
data : {
seen : "YES",
id : x
}
});
}
</script>
EDIT: w konsoli błąd wskazuje mi na coś takiego:
<script>(function() {with (this[2]) {with (this[1]) {with (this[0]) {return function(event) {openmsg('wiadomość wiadomość wiadomoooość
','KrolowaJadwiga');seenupdate('98')
};}}}})</script>
Ten post edytował Terrorizer 16.12.2014, 21:58:43