Jump to content

Response Not getting in AJAX, Pls help me


mubarakabbas

Recommended Posts

Hi.

 

When am checking with firebug, the Response Text "Done" is showing, but the value is not changing in HTML file, innerHTML=xmlhttp.responseText is not changing.  pls help me...

 

 

HTML file To replace:

 

 <div class="row">
     
         <span class="label">أختار اللغة</span>
         <span class="formw"><select size="1" name="Language_ID" onchange="getMenu(this.value)">
               <!-- START BLOCK : Language -->
              <option value="{Language_ID}" {selected}>{Language_Name}</option>
               <!-- END BLOCK : Language -->
              </select></span>
    </div>
    

     <div class="row">
     
         <span class="label">Menu Type</span>
         <span class="formw">
         
         <div id="asdfg">
  		<select style="background-color: #ffffa0" name="state"><option>Select Language First</option> </select></div>
         </span>
    </div>

 

JS FILE

 

// JavaScript Document



var xmlhttp;
//function namechange(name_fieldvalue)

function getMenu(Language_ID)
{
/*
alert(name_fieldvalue);
alert(name_fieldname);
alert(id_val);
alert(id_fieldname);
alert(table_name);
*/
/*
if (name_fieldvalue.length==0)
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
  
  */
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="findmenu.php";
url=url+"?Language_ID="+Language_ID;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  Response.ContentType = "text/plain";
	Response.Expires = -1;
	Response.CacheControl = "no-cache";

  document.getElementById("asdfg").innerHTML=xmlhttp.responseText;
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

 

 

findmenu.php

 

$response = "done";
//output the response
echo $response;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.