What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Open page in the background

Open page in the background
Author: Message:
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. Open page in the background
Hey.

I'll start making a quote from the thread, I posted earlier today:
quote:
I'm making an website for quotes for my IRC channel. The idea is, that people can send in quotes, but I do of course not want everything quoted on the site, so my idea is to combine it with MSG Plus! When people have added a quote on the website, it shall be accepted or declined in MSG Plus!

My idea is to make a list control where all quotes appears and when I press the accept/decline button a webpage should popup where I'll run some PHP codes to update the MySQL database.

As you can see, I've made som of the quote italic. I said, I want the webpage to popup, but that's not really that sensible. It makes the script have no sense at all.
Instead I'ld like the webpage to more or less one in the background. No browser should popup.

The page was ment to contain a PHP script, which connects to and updates my MySQL database. I guess that's not possible, so instead I'm "linking" to a page on my server.

Can this be done a smarter way?

Thanks in advance.
Simon Støvring
07-15-2008 06:16 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Open page in the background
Are you using POST or GET in your PHP script to read the quote you are sending to the database?
07-15-2008 06:21 PM
Profile E-Mail PM Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: RE: Open page in the background
quote:
Originally posted by matty
Are you using POST or GET in your PHP script to read the quote you are sending to the database?

Well, I could use both, what do you have in mind?

I guess GET is the easiest way in this case.
07-15-2008 06:39 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Open page in the background
Credit -dt-
-dt-'s reply to Tips

code:
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", "http://localhost/index.php", true);

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

This post was edited on 07-16-2008 at 12:34 AM by matty.
07-16-2008 12:33 AM
Profile E-Mail PM Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Open page in the background
Thanks, but I don't think, I'm using the script the right way.

quote:
function OnWinEvent_CtrlClicked(Wnd, CtrlId)
{
    switch(CtrlId)
    {   
        case "BtnAccept":
        {
            for(var i=0; i < Wnd.LstView_GetCount("ListView"); i++)
            {
                  if(Wnd.LstView_GetSelectedState("ListView", i) === true)
                  {
                      var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                    xmlhttp.open("POST", "http://www.snuzzer.dk/wowforge/admin-msgplus.php", true);
                   
                    xmlhttp.onreadystatechange=function()
                    {
                         if (xmlhttp.readyState==4)
                         {
                               Debug.Trace(xmlhttp.responseText);
                          }
                    }
                   
                    xmlhttp.send("quote=32");
                         break;
                  }
            }
            break;
        }
    }
}

I guess the xmlhttp.onreadystatechange=function() function is only for the debug trace.

But what is xmlhttp.send("quote=32"); for?

I will be able to use the get function by changing the URL in the following line:
quote:
xmlhttp.open("POST", "http://www.snuzzer.dk/wowforge/admin-msgplus.php", true);

To something smilar to:
quote:
xmlhttp.open("POST", "http://www.snuzzer.dk/wowforge/admin-msgplus.php?quote=32", true);
07-16-2008 11:12 AM
Profile E-Mail PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Open page in the background
now you changed it from POST to GET, the send('quote=32') is for the POST variables, adding the variables in the URL string is for GET.

And if the script doesn't return anything then you won't use the onreadystate function indeed, maybe only to know if you sent the quote correctly. If it does return any data, then the data will be available in this function.
[Image: 1-0.png]
             
07-16-2008 01:36 PM
Profile PM Web Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Open page in the background
Hm, okay. I couldn't seem to get POST work right, but it should be the same, if I use GET or POST in this situation, I think.
07-16-2008 02:28 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Open page in the background
Javascript:
code:
function OnWinEvent_CtrlClicked(Wnd, CtrlId){
    switch(CtrlId) {
        case 'BtnAccept': {
            for(var i=0; i < Wnd.LstView_GetCount('ListView'); i++) {
                if(Wnd.LstView_GetSelectedState('ListView', i) === true) {
                    oSendData('quote=this is a quote');
                }
            }
            break;
    }
}

function oSendData (sData) {
    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.open('POST', 'http://www.snuzzer.dk/wowforge/admin-msgplus.php', true);

    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
            Debug.Trace(xmlhttp.responseText);
        }
    }
    xmlhttp.send(sData);
}

PHP:
code:
<? echo $_POST['quote']; ?>

Also your code appears to be messed. You have one to many breaks; look at the code.

[Image: v6sqvqwd-code.jpg]

This post was edited on 07-16-2008 at 05:13 PM by matty.
07-16-2008 02:46 PM
Profile E-Mail 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