Web Analytics Made Easy -
StatCounter Help with AJAX xmlhttp and sending a value back - CodingForum

Announcement

Collapse
No announcement yet.

Help with AJAX xmlhttp and sending a value back

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with AJAX xmlhttp and sending a value back

    I am trying to figure out how to SEND something to this code from my ASP page. I am calling this fuction by checkLogin(checklogin.asp, this.form) and everything works BUT i can not tell if the user was FOUND or NOT FOUND.

    I had loggedIn set as an ASP Session but that wont work since the page needs to be refreshed in order to see those changes. How can i get a value from the checklogin.asp page after its goes into the "xmlhttp.status == 200" portion of the code?
    Code:
    function checkLogin(url, formArray) {
    var parameters = "";
    
    for(i=0; i < formArray.length; i++) {parameters = parameters + formArray[i].name + "=" + encodeURIComponent(formArray[i].value) + "&";}
    xmlhttp.open("POST", url + '?' + Math.random(), true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", parameters.length);
    xmlhttp.setRequestHeader("Connection", "close");
    xmlhttp.send(parameters);
    xmlhttp.onreadystatechange = function() {
         if (xmlhttp.readyState == 4) {
    	if (xmlhttp.status == 200) {
    		if (loggedIn  == 'NO'){
    			window.parent.openBoxShow('You were not found... try again?','')
    		}else{
    			window.parent.openBoxShow('You are now signed into the site!','RELOAD')	
    		}
            }
            else {
                    alert('An error occurred: ' + xmlhttp.status + ' ' + parameters);
            }
           	}
    }}
    Any help would be great

    David

  • #2
    Do i need to explain it better?

    David

    Comment

    Working...
    X