首页 新闻 会员 周边 捐助

html5标签,jquery插入 chrome下不显示

0
[待解决问题]
<%@ page language="java" contentType="text/html" pageEncoding="utf-8"%>
<%@page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="content" content="text/html;charset=utf-8">
<script type="text/javascript"
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">

    function ff() {
        
        $.ajax({
            type : "post",
            global : true,
            url : "servlet/ajaxServer?username=" + document.getElementsByName("username")[0],
            success : function(data, textStatus) {
                var testValue = "";    
                var testKey = "";
                if(data != null && data.length != 0){
                    testKey = data.split("=")[0].split("{")[1];
                    testValue = data.split("[")[1].split("]")[0];
                    
                    for(var i = 0; i < testValue.split(",").length; i ++){
                    //alert(testKey);
                    //alert(testValue.split(",")[i]);
                    //alert("<option label=\"" +testKey + "\"  value=\"" + testValue.split(",")[i]+ "\" />");
                        $("#testName").html("<option label=\"" +testKey + "\"  value=\"" + testValue.split(",")[i]+ "\" />");
                    
                    }
                    
                }
            }
        });
    }
    
    
</script>
</head>

<BODY>
    <h1>Automatic prompts</h1>
    <hr color="red" />
    <form method="post" action="./TestJsp">
        
            <input list="username" name="username"  id="user" oninput="ff()" />
            <datalist id="username">        
                <div id="testName"></div>            
            </datalist>
        
        
    </form>

</BODY>
</HTML>

在chrome中应该显示这样的效果,但是没有反映,大家有解决的办法么?谢谢。

 

问题补充:

url : "servlet/ajaxServer?username=" +document.getElementById("user").value,

Ruth/Christy的主页 Ruth/Christy | 菜鸟二级 | 园豆:222
提问于:2014-01-02 11:12
< >
分享
所有回答(1)
0

var strHTML="<select>";

for(var i = 0; i < testValue.split(",").length; i ++){ //alert(testKey); //alert(testValue.split(",")[i]); //alert("<option label=\"" +testKey + "\" value=\"" + testValue.split(",")[i]+ "\" />");

strHTML=strHTML+"<option label=\"" +testKey + "\" value=\"" + testValue.split(",")[i]+ "\" />");

}

strHTML=strHTML + "</select>"

$("#testName").html=strHTML;

空紫竹 | 园豆:204 (菜鸟二级) | 2014-01-02 11:35

这不是select 标签,是input type="list"

支持(0) 反对(0) Ruth/Christy | 园豆:222 (菜鸟二级) | 2014-01-02 11:46
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册