Jump to content

[SOLVED] ajax not working in explorer [all versions]


FD_F

Recommended Posts

in firefox works perfect

create object :

var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }

 

innerHTML to SELECT BOX placing in table

 

function CheckUser()
{
check = document.getElementById("Like").value;

url = "ajax.php?user=";
url+= check;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
  
  document.getElementById("add").innerHTML = xmlhttp.responseText;
  
  }
}


}

 

i think its somthing how i create the object any ideas why not working ? , thanks

in explorer i have no output in firefox i geting

<option value=test>test</option>

 

the "add" html  element is <select> inside table

 

* even epmty alert("test"); not working inside:

if(xmlhttp.readyState==4)

  {

  alert("df");

 

  }

 

i think its somthing how i create the object but i dont know whats wrong

I've seen this before. IE wont allow an html string to be inserted inside a select element where FF does allow that. Two options you have would be to either create the option elements using document.createElement() and inject every option seperately using the appendChild() function.

 

An easier way would be to rebuild the entire select element. The select element on your main page you can wrap inside a div so you can inject the html inside the div

<div id="replaceable_select_wrap">
<select>
  <option></option>
</select>
</div>

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.