Jump to content

[SOLVED] CODE WORKING WITH MOZILA AND NETSCAPE BUT NOT WITH INTERNET EXPLORER


anujphp

Recommended Posts

i am checking the presence of username while registering for my site and displaying the result using AJAX,it is working fine with mozilla and netscape and flock but now working with Internet explorer,i tried with different version of IE but none works,please help me,i am giving the js file code

 


// JavaScript Document

var xmlHttp //this will return the xmlhttp request

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;
}

//function to receive the new username and check whether th browser support ajax
function showUser(str)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="checkuser.php"
url=url+"?user="+str
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

//function to receive data from php page
function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
} 
}

 

 

THANK YOU IN ADVANCE

Link to comment
Share on other sites

hello Priti

I am a beginer of php and javascript,i dont no how to track whether script is creating xmlHttp object or not but it is definitely entering the loop where the code for xmlHttp object is created i,e the code segmentgiven below

//Internet Explorer
try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }

 

I wrote a alert statement  below this line and i got the alert.

i think it is creating  the object,if it does not create then it will give me an error message as browser does not support http request as i am checking xmlHttp by the below code

 

if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}

hope i am thinking and doing things correct.

regarding the error message i have not received any error message in the status bar,status bar is blank

thanks

 

Link to comment
Share on other sites

yes by alert only u can track....and yes you are also doing the correct way.

 

ummm ..do one thing

 

Are you sure it is not working on IE which version 7/6?

 

Track here also

 

function stateChanged()

{

alert(xmlHttp.readyState); // check which all state request goes thru !!

 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

{

document.getElementById("txtHint").innerHTML=xmlHttp.responseText

}

}

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.