ÿþv a r   x m l H t t p   =   f a l s e ;  
 v a r   x m l H t t p _ r e s p o n s e _ f u n c   =   ' x m l H t t p _ r e s p o n s e X M L ' ;  
      
 f u n c t i o n   x m l H t t p _ i n i t ( s _ u r l ,   p a r a m e t e r s ,   r e q u e s t _ t y p e ,   f u n c )   {  
     x m l H t t p   =   x m l H t t p _ g e t _ o b j e c t ( ) ;  
     i f   ( x m l H t t p   = =   n u l l )  
         r e t u r n ;  
     x m l H t t p . o n r e a d y s t a t e c h a n g e   =   s t a t e C h a n g e d ;  
     r e q u e s t _ t y p e   = =   ' '   | |   r e q u e s t _ t y p e   = =   n u l l   ?   r e q u e s t _ t y p e   =   ' G E T '   :   0 ;  
     p a r a m e t e r s   = =   ' '   ?   p a r a m e t e r s   =   n u l l   :   0 ;  
     i f   ( r e q u e s t _ t y p e   = =   ' G E T ' )   {  
         p a r a m e t e r s   ! =   ' '   & &   p a r a m e t e r s . i n d e x O f ( ' ? ' )   ! =   0   ?   s _ u r l   + =   ' ? '   +   p a r a m e t e r s   :   0 ;  
         p a r a m e t e r s   =   n u l l ;  
     }   e l s e   {  
         / / p a r a m e t e r s   ! =   ' '   & &   p a r a m e t e r s . i n d e x O f ( ' ? ' )   ! =   0   ?   p a r a m e t e r s   =   ' ? '   +   p a r a m e t e r s   :   0 ;  
     }  
     x m l H t t p . o p e n ( r e q u e s t _ t y p e ,   s _ u r l ) ;  
     i f   ( r e q u e s t _ t y p e   = =   ' P O S T ' )   {  
         / / x m l H t t p . s e t R e q u e s t H e a d e r ( " C o n t e n t - t y p e " ,   " a p p l i c a t i o n / x - w w w - f o r m - u r l e n c o d e d " ,   " c h a r s e t = U T F - 8 " ) ;  
         x m l H t t p . s e t R e q u e s t H e a d e r ( " C o n t e n t - t y p e " ,   " a p p l i c a t i o n / x - w w w - f o r m - u r l e n c o d e d " ) ;  
         x m l H t t p . s e t R e q u e s t H e a d e r ( " C o n t e n t - l e n g t h " ,   p a r a m e t e r s . l e n g t h ) ;  
         x m l H t t p . s e t R e q u e s t H e a d e r ( " C o n n e c t i o n " ,   " c l o s e " ) ;  
     }  
     i f   ( f u n c )  
         x m l H t t p _ r e s p o n s e _ f u n c   =   f u n c ;  
     x m l H t t p . s e n d ( p a r a m e t e r s ) ;  
      
 }  
  
 f u n c t i o n   x m l H t t p _ g e t _ o b j e c t ( )   {  
     v a r   x m l H t t p = n u l l ;  
     t r y   {  
         / /   F i r e f o x ,   O p e r a   8 . 0 + ,   S a f a r i  
         x m l H t t p = n e w   X M L H t t p R e q u e s t ( ) ;  
     }   c a t c h   ( e )   {  
         / / I n t e r n e t   E x p l o r e r  
         t r y   {  
             x m l H t t p = n e w   A c t i v e X O b j e c t ( " M s x m l 2 . X M L H T T P " ) ;  
         }   c a t c h   ( e )   {  
             x m l H t t p = n e w   A c t i v e X O b j e c t ( " M i c r o s o f t . X M L H T T P " ) ;  
         }  
     }  
     r e t u r n   x m l H t t p ;  
 }  
  
 f u n c t i o n   s t a t e C h a n g e d ( )   {  
     i f   ( x m l H t t p . r e a d y S t a t e   = =   4   | |   x m l H t t p . r e a d y S t a t e   = =   " c o m p l e t e " )   {    
         i f   ( x m l H t t p . s t a t u s   = =   2 0 0 )   {  
             v a r   c T y p e   =   x m l H t t p . g e t R e s p o n s e H e a d e r ( ' C o n t e n t - T y p e ' ) ;  
             i f   ( x m l H t t p . d e b u g )  
                 a l e r t ( c T y p e + ' : ' + x m l H t t p . r e s p o n s e T e x t ) ;  
             i f   ( c T y p e . s e a r c h ( / t e x t \ / p l a i n / )   >   - 1   | |   c T y p e . s e a r c h ( / t e x t \ / h t m l / )   >   - 1 )   {  
                 t r y   {  
                     i f ( t y p e o f   x m l H t t p _ r e s p o n s e _ f u n c   = =   ' f u n c t i o n ' )   {  
                         x m l H t t p _ r e s p o n s e _ f u n c ( x m l H t t p . r e s p o n s e T e x t ) ;  
                     }   e l s e   {  
                         x m l H t t p _ r e s p o n s e T e x t ( x m l H t t p . r e s p o n s e T e x t ) ;  
                     }  
                 }   c a t c h   ( e )   {  
                 }  
             }   e l s e   {  
                 t r y   {  
                     i f ( t y p e o f   x m l H t t p _ r e s p o n s e _ f u n c   = =   ' f u n c t i o n ' )   {  
                         x m l H t t p _ r e s p o n s e _ f u n c ( x m l H t t p . r e s p o n s e X M L ) ;  
                     }   e l s e   {  
                         x m l H t t p _ r e s p o n s e X M L ( x m l H t t p . r e s p o n s e X M L ) ;  
                     }  
                 }   c a t c h   ( e )   {  
                 }  
             }  
         }   e l s e  
             a l e r t ( ' B i t t e   k o n t r o l l i e r e n   S i e   I h r e   I n t e r n e t - V e r b i n d u n g   o d e r   l a d e n   S i e   g g f .   d i e   S e i t e   n e u . ' ) ;  
     }    
 }  
  
 
