I have a JavaScript widget which provides standard extension points.
(我有一个提供标准扩展点的JavaScript小部件。)
One of them is the beforecreate
function.(其中之一是beforecreate
函数。)
It should return false
to prevent an item from being created.(它应该返回false
以防止创建项目。)
I've added an Ajax call into this function using jQuery:
(我已经使用jQuery在此函数中添加了Ajax调用:)
beforecreate: function (node, targetNode, type, to) {
jQuery.get('http://example.com/catalog/create/' + targetNode.id + '?name=' + encode(to.inp[0].value),
function (result) {
if (result.isOk == false)
alert(result.message);
});
}
But I want to prevent my widget from creating the item, so I should return false
in the mother-function, not in the callback.
(但是我想防止我的小部件创建项目,因此我应该在母函数中而不是在回调中返回false
。)
Is there a way to perform a synchronous AJAX request using jQuery or any other in-browser API?(有没有一种方法可以使用jQuery或任何其他浏览器内API执行同步AJAX请求?)
ask by Artem Tikhomirov translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…