このコードが存在する私のフォームでは、optionForm divをクリックするたびにスピナー関数が起動します。最初のクリックが正常に機能し、アラートが1回発生します。再度クリックすると、2回発射されます。 3回目のクリックで3回火災などどこに問題がありますか?JQueryスピナーの問題
<script type="text/javascript">
$("#optionForm").click(function() {
$("#process").hide().ajaxStart(function() {
alert("show")
$("#process").fadeIn('100');
})
.ajaxStop(function() {
alert("hide")
$("#process").hide();
});
$.post('post_requests.php', {
scenario: ($('#scenario:checked').length ? 1 : 0),
toolkit: ($('#toolkit:checked').length ? 1 : 0),
newsletter: ($('#newsletter:checked').length ? 1 : 0),
scenarios: $('#scenarios').val(),
tools: $('#tools').val(),
news: $('#news').val(),
submit: 'yes'}, function(data) {
$("#optionResponse").html(data).fadeIn('100');
FadeMsg();
}, 'text');
function FadeMsg() {
waiting = setInterval(function() {
$('#optionResponse').fadeOut(500);
},3000);
};
clearInterval(waiting);
return false;
});
</script>
シンプルで効果的です。ありがとう。 – stevenpepe