What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » AJAX isn't working

AJAX isn't working
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: AJAX isn't working
Since you want to modify the sent message, you need to use a synchronous XMLHTTP request as opposed to an asynchronous request. You need to modify the return value of OnEvent_ChatWndSendMessage, so your script has to wait for the result before continuing execution.

This cannot and should not be done with an infinite loop!!! Your loop essentially blocks the entire Messenger thread, including the onreadystatechange callback!
js code:
function OnEvent_ChatWndSendMessage(Wnd, Message)
{
    if(Message.substr(0, 10) != "/ajax-test")
        return "";
    Debug.Trace("Retrieving " + Message.substr(11));
    var xhr = new ActiveXObject("Microsoft.XMLHTTP");
    // Note the 3rd argument: async = false, thus send() returns immediately
    xhr.open("GET", encodeURI(Message.substr(11)), false);
    xhr.send();
    if(xhr.status === 200) { // HTTP 200 OK
        // Success!
        Debug.Trace(xhr.responseText);
    } else {
        // Something went wrong...
        Debug.Trace("Error.");
    }
    // Return empty message
    return "";
}
Tip: wrap your code blocks in [code=js]...[/code] tags for beautiful JavaScript syntax highlighting! :D
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
08-29-2010 07:10 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
AJAX isn't working - by The-Phantom on 08-28-2010 at 01:33 PM
RE: AJAX isn't working - by V@no on 08-29-2010 at 05:31 AM
RE: AJAX isn't working - by The-Phantom on 08-29-2010 at 07:09 AM
RE: AJAX isn't working - by Matti on 08-29-2010 at 07:10 PM
RE: AJAX isn't working - by The-Phantom on 08-29-2010 at 07:57 PM
RE: AJAX isn't working - by CookieRevised on 08-29-2010 at 08:24 PM
RE: AJAX isn't working - by Matti on 08-29-2010 at 08:43 PM
RE: AJAX isn't working - by The-Phantom on 08-30-2010 at 06:48 AM
RE: AJAX isn't working - by CookieRevised on 08-30-2010 at 08:31 AM
RE: RE: AJAX isn't working - by The-Phantom on 08-30-2010 at 08:40 AM
RE: RE: RE: AJAX isn't working - by CookieRevised on 08-30-2010 at 09:01 AM
RE: RE: RE: RE: AJAX isn't working - by The-Phantom on 08-30-2010 at 09:22 AM
RE: AJAX isn't working - by Eljay on 08-30-2010 at 09:41 AM
RE: AJAX isn't working - by CookieRevised on 08-30-2010 at 10:12 AM
RE: AJAX isn't working - by Eljay on 08-30-2010 at 10:35 AM


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