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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.