lilman Posted February 20, 2007 Share Posted February 20, 2007 Here is my file structure. root (folder) styles/ (includes: header, footer) (folder) mysettings (file) index.php (file) body.html (folder) subscreens/ (file) profile.html (file) settings.html Now when you go to the folder mysettings, index.php calls the header and footer. It also calls body.html which calls the file settings.html in the subscreens folder. Now in the subscreens folder you have 2 files which I want to call using Ajax. the JavaScript required is typed in the header located in the styles folder. Here is that code: <script type="text/javascript"> <!-- //Create a boolean variable to check for a valid Internet Explorer instance. var xmlhttp = false; //Check if we are using IE. try { //If the Javascript version is greater than 5. xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { //If not, then use the older active x object. try { //If we are using Internet Explorer. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { //Else we must be using a non-IE browser. xmlhttp = false; } } //If we are using a non-IE browser, create a javascript instance of the object. if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { xmlhttp = new XMLHttpRequest(); } function makerequest(serverPage, objID) { var obj = document.getElementById(objID); xmlhttp.open("GET", serverPage); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { obj.innerHTML = xmlhttp.responseText; } if (xmlhttp.status==200) alert("URL Exists!") else if(xmlhttp.status==404) { alert("URL doesn't exist!"); } } xmlhttp.send(null); } //--> </script> Then the hyper link which triggers the JavaScript is in the subscreens files. Here is the hyper link: onClick="makerequest('settings.html','content'); When I run it, I get URL doesn't exist! So if anyone could help me, I think the problem is my file path but I have tried so many different ways, but cannot seem to get the right path. Thank you. 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.