Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jquery基本函数测试调用不工作?_Javascript_Jquery_Internet Explorer_Jsp - Fatal编程技术网

Javascript Jquery基本函数测试调用不工作?

Javascript Jquery基本函数测试调用不工作?,javascript,jquery,internet-explorer,jsp,Javascript,Jquery,Internet Explorer,Jsp,我的Jsp是 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%-- <%@include file="include.jsp"%> --%> <%@ taglib prefix="form" uri="../tld/spring-form.tld"%> <html> <head> &l

我的Jsp是

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- <%@include file="include.jsp"%> --%>

<%@ taglib prefix="form" uri="../tld/spring-form.tld"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<script type="text/javascript" src="../jquery/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../jquery/jqueryChat.js"></script>

</head>
<body>

    <input type="text" id="test" name="test" />
    <input type="button" value="Ajax Submit" onclick="madeAjaxCall()">
</body>
</html>
当我点击按钮时,我得到的错误是

我需要获取警报中文本框的值


非常感谢您的回答。

您好,在这里使用点击事件之前,您需要调用jquery object onload..As$(document).ready()。因此,只有ist

以下代码对我来说非常适合

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>

$(document).ready(function() {
    $("#button").click(function(){
        alert("Hello 99");
        alert($("#test").val());
    });
});

</script>

</head>
<body>

    <input type="text" id="test" name="test" />
    <input type="button" id="button" value="Ajax Submit">
</body>
</html>

在此处插入标题
$(文档).ready(函数(){
$(“#按钮”)。单击(函数(){
警报(“你好99”);
警报($(“#测试”).val();
});
});
  • 检查您的jquery.js和jqueryChat.js是否从正确的位置下载
  • 将JS代码放入
    $(document).ready(function(){..})
  • 使用
    $(“#按钮”)。单击(函数(){
    ,而不是
  • onclick=“madeAjaxCall()”


    此错误是否也发生在可靠的浏览器中?请指定您在控制台中遇到的JS错误。.您没有包含发生错误的代码…请尝试此函数madeAjaxCall(obj){alert(“Hello 99”);alert($(obj.val());}我在代码中没有看到任何问题,正在使用JS fiddle
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script>
    
    $(document).ready(function() {
        $("#button").click(function(){
            alert("Hello 99");
            alert($("#test").val());
        });
    });
    
    </script>
    
    </head>
    <body>
    
        <input type="text" id="test" name="test" />
        <input type="button" id="button" value="Ajax Submit">
    </body>
    </html>