javascript - 警报到来时组合框消失

标签 javascript jquery html alert

在我的 jsp 页面中,我有一个文本框和两个组合框。当我在文本框中写东西时,我的 jsp 页面中出现警报。警报出现为“用户名已存在”,警报后文本框自动刷新但两个组合框消失了,为什么?我找不到任何帮助的原因可能是什么?我在 head 部分包含了以下内容。警报的完整来源是 here .

http://csscody.com/demo/wp-content/demo/popup/js/jquery.easing.1.3.js

http://csscody.com/demo/wp-content/demo/popup/js/alertbox.js

http://csscody.com/demo/wp-content/demo/popup/js/style.css

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    <SCRIPT type="text/javascript" src="js/jquery.min.js"></SCRIPT>
<SCRIPT type="text/javascript" src="js/jquery.easing.1.3.js"></SCRIPT>
<SCRIPT type="text/javascript" src="js/alertbox.js"></SCRIPT>
<LINK rel="stylesheet" type="text/css" media="all" href="js/style.css">

    <script type="text/javascript">
          $(document).ready(function() {
           $("#textbox").keyup(function () {
    $.getJSON('check.jsp', {
        textboxname: this.value
    },function(data){
      if(data.isTrue){
          $("#textbox").val(''); //clear the text box
          csscody.alert("username already exists");// here alert is coming
                 }
      else{
      }
     });
});
});
    </script>
 </head>
<body>
        <input type="text" id="textbox" name="textboxname" style="position: absolute; width: 250px; left: 110px; top: 40px;" />
<br/><br/>

// The following two combo boxes are getting vanished after alert why
<select id="" name="" style="position: absolute; left: 600px; top: 40px; width: 250px;">
     <option value=""></option>
      <option value="somedata">somedata</option>
          </select>
<br/><br/> 
<select id="" >
    <option value="_"></option>
     <option value="somedata">somedata</option>
        </select>
 </body>
</html>

检查.jsp

JSONObject jsonObj= new JSONObject(); 
jsonObj.put("isTrue","true");
response.setContentType("application/json");
response.getWriter().write(jsonObj.toString());

最佳答案

你的代码没问题。当我开始调试你的代码时,我在 alertbox.js 中看到了一些有趣的东西:(第 141 和 178 行)

  if (!$.support.maxHeight) { //IE6
              $('embed, object, select').css({ 'visibility' : 'hidden' });
  }

此代码检测 ie6(如果阅读评论)但似乎有问题。

只需注释这些行,您的问题就会得到解决。

别忘了发布这个错误! 祝你好运。并开始使用调试器:)

关于javascript - 警报到来时组合框消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9347654/

相关文章:

javascript - 恶意软件将代码注入(inject)我的 Dojo/WebSocket 应用程序 : how prevent?

javascript - 判断图片宽高比是否合适

javascript - Bootstrap 下拉菜单居中对齐

php - 切换数据库 jQuery 的结果

php - 在php中生成Excel文件时显示进度条

php - 表单数据没有在按钮上提交单击到 PHP 文件

javascript - 使用表格更改 div 空间

javascript - 在 Dart 中测试性能

javascript - 显示 MarkJS 匹配的问题

javascript - 导航到另一个组件后,jquery datepicker 不工作