我正在尝试使用 ajax 提交选定的值以避免页面加载。即使使用“return false”;仍然有页面加载。数据发布成功,但页面仍然刷新。<div style='display:none;' id='RCTruckTH' name='RCTruckTH'><br><label>Height in meters *</label> <select class="form-control" style="max-width:300px!important;" id='RCTruckHV' name='RCTruckHV'> <option <?php if(isset($_SESSION['RCTruckHV']) && $_SESSION['RCTruckHV'] == "1.8m") echo "selected";?>>1.8m</option> <option <?php if(isset($_SESSION['RCTruckHV']) && $_SESSION['RCTruckHV'] == "1.9m") echo "selected";?>>1.9m</option> <option <?php if(isset($_SESSION['RCTruckHV']) && $_SESSION['RCTruckHV'] == "2.0m") echo "selected";?>>2.0m</option> </select></div>$(document).ready(function(){ $('#RCTruckHV').on('change', function() { var rcheival = $selected_value=$('#RCTruckHV option:selected').text(); localStorage.setItem('rcheival', rcheival); //console.log(rcheival); $.ajax({ url: 'RDSetSession.php', type: 'get', data: { 'rcheival': rcheival }, success: function() { location.reload(); } }); return false; });});FIX:同时删除:location.reload(); 并返回假;解决了@JayBlanchard 提到的问题
- 1 回答
- 0 关注
- 142 浏览
添加回答
举报
0/150
提交
取消