Html 如何构建PhoneGap+;没有主干的StackMob应用程序.js?

Html 如何构建PhoneGap+;没有主干的StackMob应用程序.js?,html,cordova,stackmob,Html,Cordova,Stackmob,我想构建一个带有StackMob后端的PhoneGap HTML5应用程序。关于这一主题的书籍、视频和教程似乎短缺 具体来说,如何在不使用Require.js和Backbone.js的情况下构建Phonegap+StackMob应用程序?我认为StackMob开发者网站:是最好的资源。在StackMob中使用Phonegap独立于使用Backbone.js和Require.js。StackMob SDK是使用Backbone.js构建的,用于管理模型和集合 因此,如果您想构建一个没有Backbo

我想构建一个带有StackMob后端的PhoneGap HTML5应用程序。关于这一主题的书籍、视频和教程似乎短缺


具体来说,如何在不使用Require.js和Backbone.js的情况下构建Phonegap+StackMob应用程序?

我认为StackMob开发者网站:是最好的资源。

在StackMob中使用Phonegap独立于使用Backbone.js和Require.js。StackMob SDK是使用Backbone.js构建的,用于管理模型和集合

因此,如果您想构建一个没有Backbone.js的应用程序,您可以对StackMob进行简单的AJAX调用。下面是一个JSFiddle,展示了如何使用

关于phoneGap,您需要查看以下文档

我已成功使用Adobe phoneGap build


顺便说一句,我是StackMob的平台传道者,为了更清楚,我重新格式化了问题。上面是一个“fetch”调用,是针对我们的REST API实现的,这里有文档记录:(我也为StackMob工作)
   /*
We want to prepare the Request headers we're going to send to StackMob.  It should look like:

{
  'Accept': application/vnd.stackmob+json; version=0',
  'X-StackMob-API-Key-dc0e228a-ccd3-4799-acd5-819f6c074ace': 1,
  'Range': 'objects=0-9'  //this is optional, but I did it here to show pagination and extra header fields
}

You can actually have the public key in the header as:

'X-StackMob-API-Key': dc0e228a-ccd3-4799-acd5-819f6c074ace

OR

'X-StackMob-API-Key-dc0e228a-ccd3-4799-acd5-819f6c074ace': 1

The first is our original format.  The reason why I chose the latter is because of this specific example.  I'm making cross domain requests jsfiddle.net to api.stackmob.com, which the browser doesn't allow UNLESS we use CORS (cross origin resource sharing).  StackMob servers support CORS, but it needs the latter header format to do so.  (it was introduced later).  iOS and Android SDKs use the first format.

Node.js should be able to use the first format because it doesn't restrict cross domain calls.

The "1" value in the latter format is arbitrary.  IE just doesn't allow the value of a header to be empty, so we filled it with "1".
*/

var publicKeyHeader = 'X-StackMob-API-Key-dc0e228a-ccd3-4799-acd5-819f6c074ace';
var requestHeaders = {};
requestHeaders['Accept'] = 'application/vnd.stackmob+json; version=0';
requestHeaders[publicKeyHeader] = 1;
requestHeaders['Range'] = 'objects=0-9'; //set pagination to first 10

$.ajax({
    url: 'https://api.stackmob.com/item',
    headers: requestHeaders, //set the headers
    type: 'GET',
    success: function(data, textStatus, xhr) {
        console.debug(data);
    },
    error: function(xhr, textStatus, error) {
        console.debug(error);
    }
});