using XmlTTP with XUL / XPCOM

View: New views
2 Messages — Rating Filter:   Alert me  

using XmlTTP with XUL / XPCOM

by sgetty :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I was wondering if it's possible for me to use XUL with XmlHTTP; basically, have XUL make an AJAX call to a script on my server which will return back some binary data , back to the XUL layer which is of course running on the client machine?

any help on how i can achieve this would be awesome !

-Steve

Re: using XmlTTP with XUL / XPCOM

by Dean Bayley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

req=new XMLHttpRequest();
req.onreadystatechange = function()
{
        if(req.readyState == 4 && req.status == 200)
        {
                response=req.responseText;
                //alert(response);
                if(response=='FAILED' || response=='0') return;
                else vars=eval('('+response+')');
               
                if(vars && vars['data'])
                {
                        if(vars['data']=='OK') alert("Ajax said data == OK");
                }
        }
}
if(req.readyState==4 || req.readyState==0)
{
        req.open('POST', 'http://domain.com/rpc.php', true);
        req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
        req.send('key=value');
        document.getElementById("browser").contentDocument.getElementById("status").innerHTML = 'Loading...';
}

HTH..
D.