Ajax 请求在移动设备上调用一次
Ajax request called once on mobile
代码在电脑上运行良好。但是在 windows phone(可能还有其他手机)上 ajax 请求只触发一次:
<!DOCTYPE html>
<html lang='pl'>
<head>
<title>Oświetlenie - Esp8266</title>
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css'>
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css'>
<script src='https://code.jquery.com/jquery-1.11.2.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js'></script>
<meta charset='utf-8'>
<link href='https://gitcdn.github.io/bootstrap-toggle/2.2.0/css/bootstrap-toggle.min.css' rel='stylesheet'>
<script src='https://gitcdn.github.io/bootstrap-toggle/2.2.0/js/bootstrap-toggle.min.js'></script>
</head>
<body>
<div class='row'>
<div class='col-md-2 col-md-offset-5'>
<input type='checkbox' data-toggle='toggle' id='bulbswitch' name='bulb' >
</div>
</div>
<script type='text/javascript'>
$('#bulbswitch').on('change',function(){
$.ajax({ url: '/trigger',type: 'GET'});
});
</script>
</body>
</html>
我做错了什么,mobiel phone需要特殊的请求类型?
在 ajax 上添加 cache:false
调用解决了问题:)
在 ajax 上添加 cache:false
调用解决了问题:)
代码在电脑上运行良好。但是在 windows phone(可能还有其他手机)上 ajax 请求只触发一次:
<!DOCTYPE html>
<html lang='pl'>
<head>
<title>Oświetlenie - Esp8266</title>
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css'>
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css'>
<script src='https://code.jquery.com/jquery-1.11.2.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js'></script>
<meta charset='utf-8'>
<link href='https://gitcdn.github.io/bootstrap-toggle/2.2.0/css/bootstrap-toggle.min.css' rel='stylesheet'>
<script src='https://gitcdn.github.io/bootstrap-toggle/2.2.0/js/bootstrap-toggle.min.js'></script>
</head>
<body>
<div class='row'>
<div class='col-md-2 col-md-offset-5'>
<input type='checkbox' data-toggle='toggle' id='bulbswitch' name='bulb' >
</div>
</div>
<script type='text/javascript'>
$('#bulbswitch').on('change',function(){
$.ajax({ url: '/trigger',type: 'GET'});
});
</script>
</body>
</html>
我做错了什么,mobiel phone需要特殊的请求类型?
在 ajax 上添加 cache:false
调用解决了问题:)
在 ajax 上添加 cache:false
调用解决了问题:)