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

« back to all changes in this revision

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

  • Committer: matt.giuca
  • Date: 2009-01-18 23:03:54 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1166
setup.install: Merged change from Storm branch (should have been committed
    directly to trunk). Small bugfix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
622
622
 * \param app IVLE app to call (such as "fileservice").
623
623
 * \param path URL path to make the request to, within the application.
624
624
 * \param args Argument object, as described in parse_url and friends.
625
 
 * \param method String; "GET", "POST", "PUT", or "PATCH"
626
 
 * \param content_type String, optional.
 
625
 * \param method String; "GET" or "POST"
 
626
 * \param content_type String, optional. Only applies if method is "POST".
 
627
 *      May be "application/x-www-form-urlencoded" or "multipart/form-data".
627
628
 *      Defaults to "application/x-www-form-urlencoded".
628
629
 */
629
630
function ajax_call(callback, app, path, args, method, content_type)
630
631
{
631
 
    if (!content_type)
 
632
    if (content_type != "multipart/form-data")
632
633
        content_type = "application/x-www-form-urlencoded";
633
634
    path = app_path(app, path);
634
635
    var url;
658
659
    }
659
660
    else
660
661
    {
661
 
        /* POST & PUT & PATCH sends the args in the request body */
 
662
        /* POST sends the args in application/x-www-form-urlencoded */
662
663
        url = encodeURI(path);
663
664
        xhr.open(method, url, asyncronous);
664
665
        var message;
668
669
                "multipart/form-data; boundary=" + boundary);
669
670
            message = make_multipart_formdata(args, boundary);
670
671
        }
671
 
        else if (content_type == "application/x-www-form-urlencoded")
 
672
        else
672
673
        {
673
674
            xhr.setRequestHeader("Content-Type", content_type);
674
675
            message = make_query_string(args);
675
676
        }
676
 
        else if (content_type == "application/json")
677
 
        {
678
 
            xhr.setRequestHeader("Content-Type", content_type);
679
 
            message = JSON.stringify(args);
680
 
        }
681
 
        else
682
 
        {
683
 
            xhr.setRequestHeader("Content-Type", content_type);
684
 
            message = args;
685
 
        }
686
677
        xhr.send(message);
687
678
    }
688
679
    /* Only return the XHR for syncronous requests */