~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/common/util.js

  • Committer: mattgiuca
  • Date: 2008-02-24 23:16:42 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:556
util.js: Made a function new_xmlhttprequest, for a more browser agnostic
creation of such objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
519
519
    arr.splice(j, i-j);
520
520
}
521
521
 
 
522
/** Returns a new XMLHttpRequest object, in a somewhat browser-agnostic
 
523
 * fashion.
 
524
 */
 
525
function new_xmlhttprequest()
 
526
{
 
527
    try
 
528
    {
 
529
        /* Real Browsers */
 
530
        return new XMLHttpRequest();
 
531
    }
 
532
    catch (e)
 
533
    {
 
534
        /* Internet Explorer */
 
535
        try
 
536
        {
 
537
            return new ActiveXObject("Msxml2.XMLHTTP");
 
538
        }
 
539
        catch (e)
 
540
        {
 
541
            try
 
542
            {
 
543
                return new ActiveXObject("Microsoft.XMLHTTP");
 
544
            }
 
545
            catch (e)
 
546
            {
 
547
                throw("Your browser does not support AJAX. "
 
548
                    + "IVLE requires a modern browser.");
 
549
            }
 
550
        }
 
551
    }
 
552
}
 
553
 
522
554
/** Makes an XMLHttpRequest call to the server. Waits (synchronously) for a
523
555
 * response, and returns an XMLHttpRequest object containing the completed
524
556
 * response.
542
574
     * (This is not checked against anywhere else, it is solely defined and
543
575
     * used within this function) */
544
576
    var boundary = "48234n334nu7n4n2ynonjn234t683jyh80j";
545
 
    var xhr = new XMLHttpRequest();
 
577
    var xhr = new_xmlhttprequest();
546
578
    if (method == "GET")
547
579
    {
548
580
        /* GET sends the args in the URL */