[Project_owners] send data to a web page and process it without loading to browser.

Marco Pivetta ocramius at gmail.com
Thu Jul 24 03:11:02 PDT 2008


I use tons of AJAX in my StOgame Extension ;)

As an example:

        var req=new XMLHttpRequest();
        var postdata="l="+language+"&u="+universe; //MY DATA...
        req.mozBackgroundRequest=true; //REQUEST DOESN'T GENERATE POPUPS
AND/OR CERTIFICATE AGREEMENTS ETC...
        req.onload=function()
            {
//CHECK READYSTATE
                if(
                    (req.status==200)
                    &&(req.readyState==4)
                )
                {
//CHECK IF PHP DIDNT CRASH XD
                    if(parseInt(req.responseText)==1)
                    {
                        var
expiration_timestamps=req.responseText.split(",");
                        var playerranksstatusupdate=AccountDB
                            .createStatement
                            (
                               //LET'S DO SOME COOL STUFF WITH SQLite ;)
                            );
                               //ETC...
                      }
                }
                else
                {
                    //ERROR: 404, PHP, SQL, ETC...
                }
            };
        req.onprogress=function(e)
            {
                //alert("position: "+e.position+"\nototalSize:
"+e.totalSize)
            };
        req.onreadystatechange=function()
            {
                //alert("readyState: "+req.readyState+"\nstatus:
"+req.status);
            };
        req.onerror=function()
            {
                //alert("error!!!")
            };
        req.open('POST', "
http://www.stogame.net/stogalaxy/test/rankupdatestatus.php", true);

req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//USED FOR POST DATA
        req.setRequestHeader("Content-length", postdata.length); //USED FOR
POST DATA
        req.setRequestHeader("Connection", "close");
        req.send(postdata);
    }

2008/7/24 Silver Surfer <silver.surfer444 at gmail.com>:

>
>
>
> On Thu, Jul 24, 2008 at 2:13 PM, Shivanand Sharma / Varun <
> varun21 at gmail.com> wrote:
>
>> use hidden iframe?
>>
>>   On Thu, Jul 24, 2008 at 1:50 PM, Silver Surfer <
>> silver.surfer444 at gmail.com> wrote:
>>
>>>   Hi Friends,
>>> I'm developing an new extension and I need to send some data(user
>>> input) to a web page and do some processing in there without loading that
>>> web page to the browser. ( The functionality I need is similar to the
>>> functionality of delicious firefox extension. ) But I still don't have an
>>> idea to call to script in a web browser without loading it to the browser. I
>>> would be very please if anyone of you can help me for this problems.
>>>
>>> thanks & regards,
>>> SS
>>>
>>> --
>>> ~Silver Surfer~
>>> Surfing through time & space
>>> http://risingofsilversurfer.blogspot.com/
>>>
>>> _______________________________________________
>>> Project_owners mailing list
>>> Project_owners at mozdev.org
>>> https://www.mozdev.org/mailman/listinfo/project_owners
>>>
>>>
>>
>>
>> --
>> Cheers!
>> Shivanand Sharma
>> Editor: http://binaryturf.com
>> Technology, Design, Monetization
>>
>> _______________________________________________
>> Project_owners mailing list
>> Project_owners at mozdev.org
>> https://www.mozdev.org/mailman/listinfo/project_owners
>>
>>
> thanks Shivanand,
> it's a good idea. But I have another idea, If we can use AJAX in developing
> firefox extensions, then I think I can do what I want.
>
> Can we use AJAX for developing extensions ( Most probably I think we can,
> but need to confirm that idea).
> If so I think I can call to a PHP page with relevant user data and do the
> processing of that data.
> Am I correct friends?
>
> --
> ~Silver Surfer~
> Surfing through time & space
> http://risingofsilversurfer.blogspot.com/
>
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> https://www.mozdev.org/mailman/listinfo/project_owners
>
>


-- 
Standard Ogame Project - StOgame
http://www.stogame.net
Making Ogame a better place...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mozdev.org/pipermail/project_owners/attachments/20080724/d61e685a/attachment.html>


More information about the Project_owners mailing list