Shoutbox

XMLHTTP Not Loading After Save - 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: XMLHTTP Not Loading After Save (/showthread.php?tid=81359)

XMLHTTP Not Loading After Save by bigbob85 on 02-01-2008 at 01:04 AM

Why is it ,when I use ActiveXObject("Microsoft.XMLHTTP") in my script, if I modify my script then save it, nothing will load.. Do I have to unregister it on uninitalize or something?


RE: XMLHTTP Not Loading After Save by ShawnZ on 02-01-2008 at 01:06 AM

what does it say in the debugging window?


RE: XMLHTTP Not Loading After Save by roflmao456 on 02-01-2008 at 01:11 AM

quick answer:

code:
var XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");

you are possibly forgetting to make a "new" object

what you are saying in your post is this:
code:
var XMLHTTP = ActiveXObject("Microsoft.XMLHTTP");
that code will make you [Image: throwpc.gif]
RE: XMLHTTP Not Loading After Save by bigbob85 on 02-01-2008 at 01:20 AM

I am using new... Ill go see what debuging window says.

xmlhttp isnt null, but its an empty string. Odd.. Should it be an int or something? Actualy, it was blank from the first time I used it..

What else should I trace out, all I really know is that "xmlhttp.onreadystatechange = function()" isnt triggering after it works for the first time.

I should probably just include all my code..

code:
function updateChat()
{
   var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   Debug.Trace("xmlhttp : "+xmlhttp);
   if (xmlhttp == null) Debug.Trace("Null");
   xmlhttp.open("GET", "http://www.darksignsonline.com/chatlog-light.php", false);
   xmlhttp.send("");
   xmlhttp.onreadystatechange = function()
      {
         Debug.Trace(xmlhttp.readyState);
         if (xmlhttp.readyState == 4 && xmlhttp.status)
         {
            // removed stuff that dosnt matter
         }
      }

}


I have also tried with ASYNC as true, same result. What should it be for my case?
RE: XMLHTTP Not Loading After Save by matty on 02-01-2008 at 05:37 AM

You have your xmlhttp.send(""); in the wrong place.

code:
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET", "http://www.darksignsonline.com/chatlog-light.php", true);

xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
      Debug.Trace(xmlhttp.responseText);
  }
}
xmlhttp.send('');

RE: XMLHTTP Not Loading After Save by bigbob85 on 02-01-2008 at 05:58 AM

oh wow.. yeh.. that works.
I can see why it works, but any idea why it works? (as in, technical terms) ?


RE: XMLHTTP Not Loading After Save by matty on 02-01-2008 at 12:05 PM

Because the object has no function defined if you use the .send command prior to declaring the function.


RE: XMLHTTP Not Loading After Save by bigbob85 on 02-04-2008 at 12:49 AM

Yeah, but it'll work the first time around. :S


RE: XMLHTTP Not Loading After Save by Matti on 02-04-2008 at 09:02 AM

It's just a matter of speed. (brb)

You need to use the .onreadystatechange function when you start an asynchronous XMLHTTP request, that's what the third parameter of the .open method means: asynchronous or not. When the .send() method is called, the XMLHTTP starts in another thread and will asynchronously process the request. Meanwhile, your script will continue as well. That means that, after the call to .send(), the script will try to assign the .onreadystatechange function. If the download is still busy, it will work. However, if the download is already done after you assign the .onreadystatechange function, XMLHTTP won't call your function any more, since it has already completed.

When you assign the .onreadystatechange function before you call .send(), you can be assured that the process will find your .onreadystatechange function. ;)


RE: XMLHTTP Not Loading After Save by bigbob85 on 02-04-2008 at 12:49 PM

Ohh.. Ok, thanks :D