I am trying to process data by servlet sended by jsp form using AJAX..... with 'GET' method its working okey ... but using 'POST' method to do this creating problem that onreadystatechage
condition not exectue at (xmlhttp.readyState==4 && xmlhttp.status==200)
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 || xmlhttp.status==200) {
alert("state=4 OR 200"); //for testing...
//document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
document.getElementById("TextChatHistory").value = xmlhttp.responseText;
}
}
i tryed to solve this too much .... but i cant .... Any one plz help me ..... THANK ... COMPLETE PROGRAM CODE IS GIVEN BELOW, JSP_CODE
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%--@page import="java.util.Timer.*, java.util.TimerTask.*"
Timer timer;
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script type="text/javascript" >
function AjaxFunction() {
xmlhttp = null;
if(window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
//alert("alert\_Browser");
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
//alert("alert\_ActiveX");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 || xmlhttp.status==200) {
alert("state=4 OR 200"); //for testing...
//document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
document.getElementById("TextChatHistory").value = xmlhttp.responseText;
}
}
xmlhttp.open("POST", "TextChat", true);
var Parameter\_MsgSType = "msgText=" + document.getElementById("msgText").value;
alert(Parameter\_MsgSType); //for testing...
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-lenght", Parameter\_MsgSType.lenght);
xmlhttp.setRe