Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Ajax jQuery struts
hi,
 
when I am running my site in my system where i have put my war file, that time i am getting all city according to the state but when I am accessing my sites through URL from other system that time my code is not working .
 
Here below is my code please have a look and help me ,
 
Jsp
<html:select property="stID" styleClass="textbox" önchange="collegemasterURL('collegemaster.do?method=city&stID='+ this.value);">
 

 
Ajex File :
 
function collegemasterURL(url) {
	
	if (typeof XMLHttpRequest != "undefined"){
        xmlHttp= new XMLHttpRequest();
        }
      else if (window.ActiveXObject){
        xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
        }
      if (xmlHttp==null){
      alert("Browser does not support XMLHTTP Request") ;
      return;
      } 
      xmlHttp.onreadystatechange = processStateChange;
      xmlHttp.open("GET", url, true);
      xmlHttp.send(null);
 

 
function processStateChange() {
	if (req.readyState == 4) { // Complete
		if (req.status == 200) { // OK response
			
			var returnElements = req.responseText.split("||");
			//Process each of the elements 	
			for ( var i = 0; i < returnElements.length; i++) {
				if (returnElements[i] != "") {
					valueLabelPair = returnElements[i].split(";");
					//alert(valueLabelPair[1]+''+ valueLabelPair[0]);
					document.getElementById('cntID').options.length = returnElements.length;
					document.getElementById('cntID').options[i] = new Option(
							valueLabelPair[1], valueLabelPair[0]);
 
				}
			}
		} else {
			alert("Problem: " + req.statusText);
		}
	}
}
Posted 15-Feb-12 22:53pm
Edited 15-Feb-12 23:02pm
(no name)5.1K
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 16 Feb 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100