|
||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||
Garmin.RemoteTransfer is a high-level API to transfer data to remote servers using POST, web service calls, and the like.
Version: 1.0
Author: Diana Chow diana.chow at garmin.com
| Class Summary | |
| Garmin.RemoteTransfer | Garmin.RemoteTransfer |
if (Garmin == undefined) var Garmin = {}; /** Copyright © 2007 Garmin Ltd. or its subsidiaries. * * Licensed under the Apache License, Version 2.0 (the 'License') * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @fileoverview Garmin.RemoteTransfer is a high-level API to transfer data to remote servers using POST, web service calls, and the like. * * @author Diana Chow diana.chow at garmin.com * @version 1.0 */ /** Provides the easiest avenue for getting a working instance of the plug-in onto your page. * Generates the UI elements and places them on the page. * * @class Garmin.RemoteTransfer * @constructor * @param mainElement - (String) id of the element in which to generate the contents * (can also be a reference to the dom element itself). * @param options - (Object) Object with options (see {@link Garmin.DeviceDisplayDefaultOptions} for descriptions of possible options). * * requires Prototype * @requires Garmin.DeviceControl */ Garmin.RemoteTransfer = function(){}; //just here for jsdoc //Garmin.RemoteTransfer = Class.create(); Garmin.RemoteTransfer = { //Garmin.RemoteTransfer.prototype = { initialize: function() { }, /** Open a REST request to a web service. * * @param type - the type of REST call to make * @param url - the URL of the web service endpoint * @param async - true for async, false for synch. * @param dataString - data to send with the request, if any. * @return the web service response as a JSON object. */ openRequest: function(type, url, async, dataString) { var xmlhttp = null; var jsonResult = null; var finishedResponse = false; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); if ( typeof xmlhttp.overrideMimeType != 'undefined') { xmlhttp.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert('Error: Your browser does not support xmlhttprequests.'); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { // return JSON jsonResult = JSON.parse(xmlhttp.responseText); } else { // wait for the call to complete } } xmlhttp.open(type, url, async); xmlhttp.send(dataString); return jsonResult; } };
|
||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||