我正试图在jQuery $ .post函数中执行以下fadeIn/fadeOut action。为什么POST回调函数不起作用
$.post('Scenario/SaveScenario', function (data) {
$('<div class="save-alert">The current scenario has been saved.</div>')
.insertAfter($('.buttons'))
.fadeIn('slow')
.animate({ opacity: 1.0 }, 2000)
.fadeOut('slow', function() {
$(this).remove();
});
});
但是,这不起作用,(显然)没有任何反应。 (我在Firebug中的函数内部放置了一个断点,并且它永远不会到达。)当场景被放入我的数据库时,该帖子成功发生。我不认为这是问题。
我测试了一下,只是将它作为点击事件添加到提交按钮上,并且确实有效。
$(function() {
$('#SaveScenario').click(function() {
$('<div class="save-alert">The current scenario has been saved.</div>')
.insertAfter($('.buttons'))
.fadeIn('slow')
.animate({ opacity: 1.0 }, 2000)
.fadeOut('slow', function() {
$(this).remove();
});
});
});
关于我在做什么的任何理论都是错误的?
您确定请求成功回来吗?响应在Firebug,Chrome或Fiddler中看起来如何? – 2010-08-18 22:14:32
@Nick - Spot on。哈哈......看到我对薇薇的回应。我今天赢得了我的noob点。 – JasCav 2010-08-19 14:53:28