ampersand.js 中的自定义 ajax 调用

Custom ajax calls in ampersand.js

我知道 model/collection RESTful 东西。但是我需要在 ampersand.js 中进行自定义 ajax 调用,但我似乎找不到它的 API。我应该退回到使用普通的旧 xmlhttprequest 吗?

如果自定义调用用于填充 model/collection,您应该考虑使用 ajaxConfig 选项。

否则你可以只使用像 xhr 这样 ampersand-sync 使用自己的模块来抽象 xmlhttprequest,例如:

var xhr = require("xhr")

xhr({
  body: someJSONString,
  uri: "/foo",
  headers: {
    "Content-Type": "application/json"
  }
}, function (err, resp, body) {
  // check resp.statusCode
})