我编写了一个代码,当用户不执行任何活动时会自动注销。 但有一点,我无法弄明白。 我希望当我从下拉列表中选择选项时,它将被传递给AJAX, 你可以修改它,以便我可以将选项中的数据发送到AJAX。
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<style type="text/css">
#idletimeout { background:#CC5100; border:3px solid #FF6500; color:#fff; font-family:arial, sans-serif; text-align:center; font-size:12px; padding:10px; position:relative; top:0px; left:0; right:0; z-index:100000; display:none; }
#idletimeout a { color:#fff; font-weight:bold }
#idletimeout span { font-weight:bold }
</style>
</head>
<body>
<div id="idletimeout">
You will be logged off in <span><!-- countdown place holder --></span> seconds due to inactivity.
<a id="idletimeout-resume" href="#">Click here to continue using this web page</a> Please select reason for being idle.
<select id='idleReason' size="1">
<option value="nothing" selected="selected">Select a site</option>
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
<option value="Option 4">Option 4</option>
</select>
</div>
Content Lorem Impsum
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript"></script>
<script src="jquery.idletimer.js" type="text/javascript"></script>
<script src="jquery.idletimeout.js" type="text/javascript"></script>
<script type="text/javascript">
$.idleTimeout('#idletimeout', '#idletimeout a', {
idleAfter: 3,
pollingInterval: 2,
keepAliveURL: 'keepalive.php',
serverResponseEquals: 'OK',
onTimeout: function(){
$(this).slideUp();
window.location = "timeout.htm";
},
onIdle: function(){
$(this).slideDown(); // show the warning bar
},
onCountdown: function( counter ){
$(this).find("span").html( counter ); // update the counter
},
onResume: function(){
$(this).slideUp(); // hide the warning bar
}
});
//
</script>
</body>
</html>
我很感激你。
答案 0 :(得分:0)
jQuery函数的基本形式应如下所示:
$('#idleReason').change(function(){
$.ajax({
url: 'http://www.your.ajax.handler'
data: $('#idleReason option:selected').html()
});
);
您应该查看ajax documentation,了解有关如何自定义查询的详细信息。