本文整理匯總了TypeScript中dojo/request/xhr.post函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript post函數的具體用法?TypeScript post怎麽用?TypeScript post使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了post函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
'.post with query': function () {
var def = this.async(),
promise = xhr.post('/__services/request/xhr', {
query: {
foo: [ 'bar', 'baz' ],
thud: 'thonk',
xyzzy: 3
},
data: { color: 'blue' },
handleAs: 'json'
});
promise.then(
def.callback(function (data) {
assert.strictEqual(data.method, 'POST');
var query = data.query,
payload = data.payload;
assert.ok(query);
assert.deepEqual(query.foo, [ 'bar', 'baz' ]);
assert.strictEqual(query.thud, 'thonk');
assert.strictEqual(query.xyzzy, '3');
assert.ok(payload);
assert.strictEqual(payload.color, 'blue');
}),
def.reject
);
},
示例2: post
function post(headers) {
return xhr.post('/__services/request/xhr', {
query: {
'header-test': 'true'
},
headers: headers,
data: 'testing',
handleAs: 'json'
});
}
示例3: function
export let post = function(url: string, option: any) {
if(option.data && typeof option.data == 'object') {
option.data.csrfmiddlewaretoken = cookie('csrftoken');
}
return xhr.post(url, option);
}