Return to Snippet

Revision: 43373
at March 22, 2011 22:56 by kangcom


Initial Code
############################
html file
############################


<script language=javascript>

	var xmlHttp_1 = null;
	var objDiv_1 = null;
	var htmlContents_1 = null;

	function createXMLHttpRequest_1() {
		if (window.ActiveXObject) {
			xmlHttp_1 = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		else if (window.XMLHttpRequest) {
			xmlHttp_1 = new XMLHttpRequest();
		}
	}

	function handleStateChange_1() {
	
		if(xmlHttp_1.readyState == 4) {
			if(xmlHttp_1.status == 200) {
				htmlContents_1 = xmlHttp_1.responseText;
				objDiv_1.innerHTML = htmlContents_1;
			}
		}
	}


	
	function getContents_1(url, divv) {

			objDiv_1 = document.getElementById(divv);

			createXMLHttpRequest_1();
			xmlHttp_1.onreadystatechange = handleStateChange_1;
			
			xmlHttp_1.open("GET", url, true); 
			xmlHttp_1.send(null);
	}

	function send(name, layer) {
		getContents_1("./idchk.php?id="+name,layer);
	}

</script>


<form>
	<input name=n type=text size=10>
	<input type=button value=Input onClick=send(this.form.n.value,'layer1')>
</form>

<!-- result -->
<div ID="layer1"></div>



############################
php file (idchk.php)
############################

<?


	echo "You can use <b>".$_GET['id']."</b>";
?>

Initial URL

                                

Initial Description

                                

Initial Title
Checking of duplicated userid using XMLHTTP (or AJAX)

Initial Tags
ajax

Initial Language
JavaScript