Hello Everyone,
I am having tuff time to find the solution that why my readystate is stick to 1 it is not shifting to 4?>>>
my js
var gShow; //error handling
var sUrl = "formvalidation.php?validationtype=ajax&val=";
var gErrors = 0;
var http = getHTTPObject();
var continueSubmit = false ;
function attachFormHandlers()
{
var form = document.getElementById('form1')
if (document.getElementsByTagName)
{
var objInput = document.getElementsByTagName('input');
for (var iCounter=0; iCounter<objInput.length; iCounter++)
{
if(document.form1.elements[iCounter].type=='text')
{
alert("calling validateme for "+document.form1.elements[iCounter]);
validateMe(document.form1.elements[iCounter]);
}
}
}
// form.onsubmit = function(){return validate();}
}
/*validateMe is the function called with onblur each time the user leaves the input box
passed into it is the value entered, the rules (which you could create your own), and the id of the area the results will show in*/
function validateMe(objInput) {
sVal = objInput.value;
if(sVal != 'Submit')
{
alert(sVal);
sRules = objInput.className.split(' ');
sRequired = encodeURI(sRules[1]);
sTypeCheck = encodeURI(sRules[2]); //typecheck are additional validation rules (ie. email, phone, date)
gShow = sRules[3];
/*Post*/
str=sUrl + sVal + "&sRequired=" + (sRequired) + "&sTypeCheck=" + sTypeCheck;
http.open("POST","/Prj/ph/php/formvalidation.php",true);
http.setRequestHeader("Content-type","application/x-www-form-urlencoded");
http.setRequestHeader("Content-length",str.length);
http.setRequestHeader("Connection", "close");
alert("Before onnreadystatechange"+http.readyState);
http.onreadystatechange=handleHttpResponse();
alert("After onnreadystatechange"+http.readyState);
http.send(str);
}else
{
alert("gerrors"+gErrors);
if(gErrors <= 0 )
{
document.form1.submit();
}else
{
alert("fill your form");
return false;
}
}
/*GET
http.open("GET", sUrl + (sVal) + "&sRequired=" + (sRequired) + "&sTypeCheck=" + sTypeCheck, true);
http.onreadystatechange = handleHttpResponse; // handle what to do with the feedback
http.send(null); */
}
function handleHttpResponse() {
alert("handle response"+http.readyState);
if (http.readyState == 4)
{
if (http.status == 200)
{
sResults = http.responseText.split(","); //results is now whatever the feedback from
alert("innerhtml "+document.getElementById(gShow).innerHTML);
alert(document.getElementById(gShow).innerHTML);
document.getElementById(gShow).innerHTML = "";
if(sResults[0] != "OK")
{
gErrors = gErrors + 1;
}
document.getElementById(gShow).innerHTML=http.responseText;
}
else if (http.status == 404) {
alert ("Requested URL is not found.");
}
else if (http.status == 403) {
alert("Access denied.");
}else
{
document.getElementById(gShow).innerHTML="status is : "+http.status;
}
}
}
function validate()
{
attachFormHandlers();
}
function getHTTPObject() {
var xmlhttp=null;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
//xmlhttp.overrideMimeType('text/html');
}
else if (window.ActiveXObject) {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}
I just wanted to know also that how to send plan text in the response (PHP as server side scriptiong)
it would be gr8 if someone can help me to understand the issue why it is sticking to 1 i am just not finding the way out
any help any guidance would be highly appreciated
Thansk & Regards,
Priti




-: 

Bookmarks