What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Fetch Webpage without Freezing WLM [SOLVED]

Fetch Webpage without Freezing WLM [SOLVED]
Author: Message:
prashker
Veteran Member
*****


Posts: 5109
Reputation: 104
– / Male / –
Joined: Mar 2005
Status: Away
O.P. Fetch Webpage without Freezing WLM [SOLVED]
Javascript code:
    var temp = WinHttpReq.Open("GET", "http://sonicsam.net/xboxXXX.php?"+date.getTime(), false);
    WinHttpReq.Send();
    strResult = WinHttpReq.ResponseText;


WLM freezes until the page has completely loaded (even in the browser, because of the functions I use in the PHP code, it takes a few seconds).

How can I do this in a way that WLM will not freeze.

I had an idea, maybe download the page via wget, then load the file locally, and read that. However this script runs every 5 minutes and I don't want a wget command prompt window coming up every 5 minutes (and I would have to add a timer, because wget wouldn't be able to tell the script that it is done downloading the page, proceed to read it) But I guess there is code to check that 'while file doesn't exist, check if file exists'

This post was edited on 07-02-2009 at 08:47 PM by prashker.
07-02-2009 07:55 PM
Profile PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: Fetch Webpage without Freezing WLM
You can make the operation asynchronous by passing true as the third parameter in the Open method.

On a side note, why don't you use XMLHttpRequest? It has ResponseText too :p
07-02-2009 08:00 PM
Profile PM Web Find Quote Report
prashker
Veteran Member
*****


Posts: 5109
Reputation: 104
– / Male / –
Joined: Mar 2005
Status: Away
O.P. RE: Fetch Webpage without Freezing WLM
quote:
Originally posted by Mnjul
You can make the operation asynchronous by passing true as the third parameter in the Open method.

Error: The data necessary to complete this operation is not yet available.
(code: -2147483638)
07-02-2009 08:14 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Fetch Webpage without Freezing WLM
Javascript code:
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open('GET', 'http://sonicsam.net/xboxXXX.php?'+date.getTime(), true);
 
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) {
            Debug.Trace(xmlhttp.responseText);
        }
    }
   
    xmlhttp.send('');

07-02-2009 08:19 PM
Profile E-Mail PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: Fetch Webpage without Freezing WLM
Indeed, you need to call Waitforresponse() which wait until the data is ready :p ...and that would still block your program.

I now see using WinHttpRequest maybe not suitable for single-thread, so why not XMLHttpRequest? (A)

This post was edited on 07-02-2009 at 08:20 PM by Mnjul.
07-02-2009 08:20 PM
Profile PM Web Find Quote Report
mynetx
Skinning Contest Winner
*****

Avatar
Microsoft insider

Posts: 1175
Reputation: 33
36 / Male / Flag
Joined: Jul 2007
RE: Fetch Webpage without Freezing WLM
JScript code:
var objAjax = new ActiveXObject("Microsoft.XMLHTTP");
var strUrl = "http://sonicsam.net/xboxXXX.php?" + new Date().getTime();
objAjax.open("GET", strUrl, true); // asyncobjAjax.onreadystatechange = function() {
    if(objAjax.readystate != 4)
        return;
    var intStatus = 12027;
    try {
        intStatus = objAjax.status;
    }
    catch(e) { }
    if(intStatus != 200) {
        Debug.Trace("Web connection error " + intStatus);
        return;
    }
    Debug.Trace(objAjax.responseText);
};
objAjax.send();

mynetx - Microsoft, enhanced.

You have a problem or issue with Windows, Internet
Explorer or Office?
Send a tweet!
07-02-2009 08:21 PM
Profile E-Mail PM Web Find Quote Report
prashker
Veteran Member
*****


Posts: 5109
Reputation: 104
– / Male / –
Joined: Mar 2005
Status: Away
O.P. RE: Fetch Webpage without Freezing WLM
matty's code worked, thanks :banana:
quote:
Originally posted by Mnjul
I now see using WinHttpRequest maybe not suitable for single-thread, so why not XMLHttpRequest?
psh :D
07-02-2009 08:47 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On