Ajax and jsp related query.

Morningdot Hablu

Morningdot Hablu

@morningdot-6Xuj4M Oct 27, 2024
hello friend's
Don't know why ajax is not working with my jsp pages.Look at this code
<html>
<script>
    function check()
    {
        //alert("mohit kumar singh");
        var k=document.getElementById("d2").value;
        //alert(k);
        if(window.XMLHttpRequest)
        {
            xmlhttp=new XMLHttpRequest();
        }
        else
        {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function()
        {
            if(xmlhttp.readyState==4 && xmlhttp.status==200)
            {
                document.getElementById("mydiv").innerHTML=xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET","new.jsp?t1="+k,true);
        xmlhttp.send();
    }
</script>
<body bgcolor="yellow">
<center>
<h1>Ajax Application</h1>
<div id="mydiv">
</div>
<form name="f1" id="d1">
<input type="text" name="t2" id="d2">
<input type="button" value="click here" onclick="check();">
</form>
</center>
</body>
</html>
and here goes the 2nd one
<h1><%=t1%></h1>
but don't know why it's not working.

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform