I have a mobile site where I am using JavaScript to refresh a message counter, JavaScript is enabled but it does not update the counter. The phone I am testing on is a Nokia e90. the other test phone is an HTC innovation and it works perfect on there.
Is it a issue of the JavaScript version on the e90 is out of date?
Here is my JS:
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo TITLE_HOME;?></title>
<meta http-equiv="content-language" content="en" />
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="include/js/jquery-1.3.2.min.js"></script>
<!-- like this-->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0b2.min.css" />
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0b2.min.js"></script>
<script>
$(document).ready(function()
{
refresh();
});
function refresh()
{
$.get('newMessageCnt.php', function (cnt) {
$("#msgcntDiv").html("You have " + cnt);
//console.log(cnt);
//$("#msgcntDiv").text("You have " + cnt);
window.setTimeout(refresh,30000);
});
}
</script>
and the php:
<?php
if ($numOfMessages <> 0)
{
echo "<span class='headings_sub' id='msgcntDiv'>You have " .$numOfMessages . "</span>";
echo "<a class='red_link' href='".ADDRESS."messages.php'> unopened Messages</a>";
}
else
{
echo "<span class='headings_sub'>You have no new messages</span>";
}
?>
on the HTC $numOfMessages updates without a blink. On the E90 nothing happens
Try and add the id to the else echo statement
If you start with 0 messages then if other messages come you won’t have a span id to update the text.