gpt4 book ai didi

javascript - 在 &ersand.js 中自定义 ajax 调用

转载 作者:行者123 更新时间:2023-11-30 09:52:52 25 4
gpt4 key购买 nike

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

最佳答案

如果自定义调用用于填充模型/集合,您应该考虑使用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
})

关于javascript - 在 &ampersand.js 中自定义 ajax 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35481127/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com