I'm trying to write some ajax script, but even the simple one like below is not working in both IE and Firefox on my computer. What's wrong with the script? Or shall I change any settings for my browser?
Hi, you need some sort of server on your local machine, to make it working. LAMP, XAMPP, whatever suits you...
i'm not sure if this is the solution but i think it needs another closing } to close the function and </script> on the end
you also need to call the function. The changes are in bold. <script language="javascript"> var xmlHttp; function createAjax(){ try{ xmlHttp = new XMLHttpRequest(); //for Firefox, Safari, etc alert("Your browser is Firefox!"); }catch(e){ try{ xmlHttp = new ActiveXObject("Msxml12.XMLHTTP"); //Internet Explorer 7.0 alert("Your browser is IE7"); }catch(e){ try{ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); //IE4.0 -7.0 alert("Your browser is IE5"); }catch(e){ alert("Your browser doesn't support Ajax!"); return false; } } } [B]} createAjax(); </script> Code (markup): [/B] IE7 Does support XMLHTTPRequest, so IE7 will say it is firefox, you could change the order to put IE7 first and it would work, but it doesn't really matter, as long as it works.
and all AJAX code must be excuted online (localhost or real host) you can not run at with local files
Yes, after uploading the files to my server and testing it, it's working fine. Previously I just preview the html file on my computer.
I don't want to put files on local server. I need to make an ajax call to the local files. In Firefox everything works fine. In IE ajax call to html files works fine but it doesn't work when call is made to xml file. Can someone help me out?