Update checker - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Update checker (/showthread.php?tid=81270)
Update checker by ArkaneArkade on 01-28-2008 at 04:37 PM
Hey guys, I'm really struggling with something here, I've tried to add an update checker to my script.
code: function CheckforUpdates()
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET","http://arkanes-arkade.co.uk/XBox/ScriptVersion.txt", true);
xmlhttp.send(Math.round(Math.random()*99999));
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
{
var resp = xmlhttp.responseText;
Debug.Trace(resp);
if(resp != "Version: " + ScriptVersion)
{
resp=resp.split(" ");
if(resp[1]>ScriptVersion)
{
MsgPlus.DisplayToast("XBMC", "Script Update Available!\nClick here to download now", "", "ScriptUpdate", ScriptVersion);
}
}
}
xmlhttp.close;
}
}
I don't understand the problem. Every time I get the toast popup. I added the debug to find out what my reply was, and I get these errors.
code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>The page cannot be displayed</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<STYLE type="text/css">
BODY { font: 8pt/12pt verdana }
H1 { font: 13pt/15pt verdana }
H2 { font: 8pt/12pt verdana }
A:link { color: red }
A:visited { color: maroon }
</STYLE>
</HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD>
<h1>The page cannot be displayed</h1>
The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.
<hr>
<p>Please try the following/p>
<ul>
<li>Contact the Web site administrator if you believe that this request should be allowed.</li>
<li>Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly. </li>
</ul>
<h2>HTTP Error 405 - The HTTP verb used to access this page is not allowed.<br>Internet Information Services (IIS)</h2>
<hr>
<p>Technical Information (for support personnel)</p>
<ul>
<li>Go to <a href="http://go.microsoft.com/fwlink/?linkid=8180">Microsoft Product Support Services</a> and perform a title search for the words <b>HTTP</b> and <b>405</b>.</li>
<li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr),
and search for topics titled <b>Setting Application Mappings</b>, <b>Securing Your Site with Web Site Permissions</b>, and <b>About Custom Error Messages</b>.</li>
</ul>
</TD></TR></TABLE></BODY></HTML>[code]
I've contacted my host, but they tell me there is no reason for this error except due to my script being wrong. I don't think this is the case to be completely honest, as it worked with a free site, but if they aren't letting me get anywhere I have to try this. I need some way to adapt this to work with my site. any ideas?
Cheers all
[/code]
RE: Update checker by Matti on 01-28-2008 at 05:51 PM
I think there's a problem with:
code: xmlhttp.send(Math.round(Math.random()*99999));
because a "normal" GET query looks like "key=value&this=that", although I know that "page.php?81256" should work too...
Although, there's a much better way to make sure that the downloaded file is always the latest version from the server. The Win32 API function "DeleteUrlCacheEntryW" will make sure that the cached version of the requested page is removed before you execute the XmlHttp request.
code: var sUrl = "http://arkanes-arkade.co.uk/XBox/ScriptVersion.txt";
Interop.Call('wininet.dll', 'DeleteUrlCacheEntryW', sUrl); //Clear URL from cache
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET", sUrl, true);
xmlhttp.send();
RE: Update checker by ArkaneArkade on 01-28-2008 at 09:05 PM
Thank you sooooo much Mattike. Thats absolutely perfect
|