www.webdeveloper.com
Results 1 to 8 of 8

Thread: Ajax

Threaded View

  1. #1
    Join Date
    Jan 2011
    Posts
    6

    Ajax

    below my java Script is there
    it is not entering after if(xmlObj.readystate == 4 & xmlObj.status == 200)
    please help me..,

    Code:
    function GetXmlHttpObject()
    {
    	var xmlHttp=null;
    	try
    	{
    		// Firefox, Opera 8.0+, Safari
    		xmlHttp=new XMLHttpRequest();
    	}
    	catch (e)
    	{
    		// Internet Explorer
    		try
    		{
    			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    		}catch (e)
    		{
    			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    		}
    	}
    	return xmlHttp;
    }
    var xmlObj = GetXmlHttpObject();
    
    function getCityData()
    {
    	var stateValue = document.getElementById("State").value;
    	
    	url = "http://localhost:8085/NewForm/getCity.jsp?State="+stateValue;
    	alert(url);
    	xmlObj.open("GET",url,true);
    	
    	xmlObj.onreadystatechange = function()	{  
    		//alert(xmlObj.status);
    		//alert(xmlObj.readystate);
    		alert(xmlObj);
    		if(xmlObj.readystate == 4 & xmlObj.status == 200)
    		
    		{
    					alert(xmlObj.readystate);
    			alert("jerald");
    			alert(xmlObj.responseText);
    			//var id =
    				document.getElementById("City");
    			
    			var result = xmlObj.responseText;
    			alert(result);
    				
    			var s = result.split(',');
    			var indx = 1;
    			for(indx=1; indx < s.length; indx++)
    			
    			{
    				document.form1.City.options[s[indx]] = new Option(s[2],s[1]);
    			
    			}
    			
    			}
    	}
    	xmlObj.send(null);
    }
    Last edited by Kor; 01-07-2011 at 09:57 AM. Reason: wrap the code [code][/code]

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles