您可以通过我的javascript确认提示3次点击执行任何命令。我的所有代码都嵌套在handle-request ajax函数中。这是我的代码,我不知道为什么这样做?
closeButton.onclick = function() {
node.setData('alpha', 0, 'end');
node.eachAdjacency(function(adj) {
adj.setData('alpha', 0, 'end');
var requestone = createRequest();
var deletenode = node.id;
var vars = "deletenode=" + encodeURIComponent(deletenode);
requestone.open("POST", "deletenode.php", true);
requestone.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
if (confirm('Are you sure you want to delete this species from the Database?')) {
requestone.onreadystatechange = function()
{
handleRequest(requestone);
};
requestone.send(vars);
fd.fx.animate({
modes: ['node-property:alpha',
'edge-property:alpha'],
duration: 500
});
} else
{
// Do nothing!
}
});
答案 0 :(得分:0)
这并不意味着,它需要3次点击。你必须等到操作完成。然后只有你会得到答复。这意味着readyState变为4.
readyState是HTTPRequest的属性之一。它指示对象的当前状态。
有5个州。
0 - 未初始化(UNSENT)
1 - 装载(打开)
2 - 加载(HEADERS_RECEIVED)
3 - 互动(LOADING)
4 - 完成(完成)