Whats wrong in this ajax code? this is working fine in IE but not working in firefox.?
-
here is my code, its working fine in IE but not in FF? can you pls write the correct code if possible. <script type="text/javascript" language="javascript"> function displaydetail(id) { if(window.ActiveXObject) { var req=new ActiveXObject('Microsoft.XMLHttp'); } else if(window.XMLHttpRequest) { var req=new XMLHttpRequest(); } req.open('GET','dosql.php?id='+id,tru… connection //alert(id); req.onreadystatechange=function() { if(req.readystate==4) { if(req.status==200) { var resp=req.responsetext; document.getElementById('detail').… } } } req.send(); } </script>
-
Answer:
Hmmm. You need some error checking code. Try checking to see if req.send() is successful or even if req was created properly. If all of that is working, check what req.status is when the request completes. Or even readystate...
parwan00... at Yahoo! Answers Visit the source
Other answers
Try This... <script type="text/javascript" language="javascript"> function displaydetail(id) { if(window.ActiveXObject) { var req=new ActiveXObject('Microsoft.XMLHttp'); } else if(window.XMLHttpRequest) { var req=new XMLHttpRequest(); } req.open('GET','dosql.php',true); //change these req.onreadystatechange=function() { if(req.readyState==4) { if(req.status==200) { var resp=req.responseText; //change these alert(resp); //change these } } } req.send(null); } </script> CHANGES MADE: req.send() -> req.send(null) responsetext -> responseText readystate -> readyState Cheers!
There is just a support of IE Try to add code for Firefox much better to use some lib those are compatible with all browsers There are Jquery or prototype http://www.zahipedia.com
Related Q & A:
- Whats wrong with my msn?Best solution by Yahoo! Answers
- Whats wrong with my TI-84 calculator?Best solution by Yahoo! Answers
- Whats wrong with my lawn mower?Best solution by Yahoo! Answers
- Whats wrong with my DVD recorder?Best solution by Yahoo! Answers
- Whats wrong with my 93 lincoln?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.