Drezard Posted July 31, 2008 Share Posted July 31, 2008 Trying to get some basic PHP and ajax up and running. Here is my first example: <?php session_start(); ?> <html> <head> </head> <body> <script type="text/javascript"> var xmlhttp = false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); alert("You are using Microsoft Internet Explorer"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); alert("You are using Microsoft Internet Explorer"); catch(E) { xmlhttp = false; alert("You are not using Microsoft Internet Explorer"); } } </script> </body> </html> This just provides a blank white page. Whats wrong? Daniel Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 31, 2008 Share Posted July 31, 2008 you were missing a close brace before the second CATCH: <?php session_start(); ?> <html> <head> </head> <body> <script type="text/javascript"> var xmlhttp = false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); alert("You are using Microsoft Internet Explorer"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); alert("You are using Microsoft Internet Explorer"); } catch(E) { xmlhttp = false; alert("You are not using Microsoft Internet Explorer"); } } </script> </body> </html> if you are REALLY interested in learning exactly how the XMLHTTP object works, feel free to keep going down this road. But if you are more interested in what you can DO with AJAX, I would recommend using a JavaScript library. The popular ones are jQuery, Prototype, and MooTools. They have easy functions that make AJAX cross-browser friendly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.