Jump to content

I need help in ajax


php_developer

Recommended Posts

You create it by creating the ActiveXObject like the tutorial shows, that's how IE6 supports ajax. If it doesn't work for you then you're not doing something right. Maybe you're just double-clicking to open the file and it's running with increased security and blocking Javascript. Maybe you're trying to send a request to an external domain. I don't know why it's not working for you because I'm not watching you and you haven't said exactly what you're doing and exactly what is happening, but the code in the tutorial is how you use ajax in IE6. If you're not checking for Javascript error messages, that would be a good idea also.

Link to comment
Share on other sites

I have two select boxes, one for country and other for time zone...depending upon the country the time zone will apper in second select box... my code is working well on mozilla, chrome..but not at all working on IE6... I have used different ajax codes but every code works properly on browsers except for IE6... Here are the ajax code... first is.. I have used the code fromhttp://www.w3schools...uest_create.asp next time I used as follows. try{ // Opera 8.0+, Firefox, Safari xmlhttp = new XMLHttpRequest(); } catch (e) { // Internet Explorer Browsers try{ return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) { try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { // Something went wrong alert("Your browser broke!"); return false; } } } }xmlhttp.open("GET","process.php?q="+str,true);xmlhttp.send(); and the other is ... // Needed for IE6 and older to replicate the standard XMLHttpRequest objectif (window.ActiveXObject && !window.XMLHttpRequest){window.XMLHttpRequest = function(){progIds=new Array("Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP", "Microsoft.XMLHTTP");for(i in progIds){try{return new ActiveXObject(progIds);}catch(ex){alert(progIds);}}return null;};} xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("timezone").innerHTML=xmlhttp.responseText; } }xmlhttp.open("GET","process.php?q="+str,true);xmlhttp.send(); ( These all are not woking only on IE6)I have used POST rather than using GET also...

Link to comment
Share on other sites

I have two select boxes, one for country and other for time zone...depending upon the country the time zone will apper in second select box... my code is working well on mozilla, chrome..but not at all working on IE6... I have used different ajax codes but every code works properly on browsers except for IE6... Here are the ajax code... first is.. I have used the code fromhttp://www.w3schools...uest_create.asp next time I used as follows. try{ // Opera 8.0+, Firefox, Safari xmlhttp = new XMLHttpRequest(); } catch (e) { // Internet Explorer Browsers try{ return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) { try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { // Something went wrong alert("Your browser broke!"); return false; } } } } xmlhttp.open("GET","process.php?q="+str,true);xmlhttp.send(); and the other is ... // Needed for IE6 and older to replicate the standard XMLHttpRequest objectif (window.ActiveXObject && !window.XMLHttpRequest){window.XMLHttpRequest =function(){progIds=new Array("Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP");for(i in progIds){try{return newActiveXObject(progIds);}catch(ex){alert(progIds);}}return null;};} xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("timezone").innerHTML=xmlhttp.responseText; } }xmlhttp.open("GET","process.php?q="+str,true);xmlhttp.send(); ( These all are not woking only on IE6)I have used POST rather than using GET also...
how did you get that from the example in the link?
var xmlhttp;if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else  {// code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }

are you checking your error console at all before you start changing your code?

Link to comment
Share on other sites

What happens when you run the code? Is there an error message, does the alert box show? Saying "it doesn't work" doesn't give us any information to help solve the problem.
working of ajax...When I select the country from the country select box then time zone for that particular country displayed on another select box ( which I have saved in database )... and Its working properly on all browers except on IE6... Problem...as on IE6 the time zone select box remains empty on selection of any country...So that means its not working... and also... the status bar of brower shows "Error on page" ( at left corner of status bar )...
Link to comment
Share on other sites

working of ajax...When I select the country from the country select box then time zone for that particular country displayed on another select box ( which I have saved in database )... and Its working properly on all browers except on IE6... Problem...as on IE6 the time zone select box remains empty on selection of any country...So that means its not working... and also... the status bar of brower shows "Error on page" ( at left corner of status bar )...
ding ding ding ding!
are you checking your error console at all before you start changing your code?
maybe that's a hint you should try and find out what the error is...?
Link to comment
Share on other sites

ding ding ding ding! maybe that's a hint you should try and find out what the error is...?
I have already seen the error but It was not clear with it.. so I asked dear :Pleased: ....
Show your entire code and double-click on the error icon to figure out what it's telling you is the problem.
( I know that I didn't give the full code to you... full code may help you to solve the problem.. But my question was just for to check the ajax code.. because I do not know much about ajax... so I thought that I am doing some mistake in ajax... ) But now I got the answer... The problem was in "document.getElementById("txtHint").innerHTML=xmlhttp.responseText;" The innerhtml that I am using is not working in IE6 every thing else is okay... I thought that if every thing is working properly on other browsers then what is the problem with IE6?... I checked each and every line and now I got the answer... Thanks alot for replying and giving time to my Post.. :rolleyes:
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...