Hi guys,
Let me just introduce my problem - i hope someone will be able to help! I have an index page for my site where i want the user to have the choice to view a login form or registration form. I have index.php with two links ("Click to login", "Click to Register"). I want to use ajax so that the user can switch between the forms without having to load the page. At the moment i have the forms stored in seperate html pages and i want the revelvant page to fill itself into a div called "content", depending on what the user would like to see. Here is my code:
In firefox only the registration link is working (or so it seems). In IE it is the same, although it tells me that there is an object expected on line 48 ("httpRequest2. overrideMimeTyp e('text/xml')"). Is it ok to have two ajax function s on the same page, after all they shouldnt be both being used at the same time?
Thanks for your time guys.
Chris
Let me just introduce my problem - i hope someone will be able to help! I have an index page for my site where i want the user to have the choice to view a login form or registration form. I have index.php with two links ("Click to login", "Click to Register"). I want to use ajax so that the user can switch between the forms without having to load the page. At the moment i have the forms stored in seperate html pages and i want the revelvant page to fill itself into a div called "content", depending on what the user would like to see. Here is my code:
Code:
<html> <head> <script type="text/javascript" language="javascript"> function registerRequest() { var httpRequest; var url="registration_form.php" if (window.XMLHttpRequest) { // Mozilla, Safari, ... httpRequest = new XMLHttpRequest(); if (httpRequest.overrideMimeType) { httpRequest.overrideMimeType('text/xml'); // See note below about this line } } else if (window.ActiveXObject) { // IE try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } if (!httpRequest) { alert('Your browser does not support the features needed for this website'); return false; } httpRequest.onreadystatechange = function() { if (httpRequest.readyState == 4) { if (httpRequest.status == 200) { document.getElementById('content').innerHTML = httpRequest.responseText; } else { alert('There was a problem with the site.'); } } }; httpRequest.open('GET', url, true); httpRequest.send(''); httpRequest.close; } function loginRequest() { var httpRequest2; var url2="login_form.php" if (window.XMLHttpRequest) { // Mozilla, Safari, ... httpRequest2 = new XMLHttpRequest(); if (httpRequest2.overrideMimeType) { httpRequest2.overrideMimeType('text/xml'); // See note below about this line } } else if (window.ActiveXObject) { // IE try { httpRequest2 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { httpRequest2 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } if (!httpRequest2) { alert('Your browser does not support the features needed for this website'); return false; } httpRequest2.onreadystatechange = function() { if (httpRequest2.readyState == 4) { if (httpRequest2.status == 200) { document.getElementById('content').innerHTML = httpRequest2.responseText; } else { alert('There was a problem with the site.'); } } }; httpRequest2.open('GET', url2, true); httpRequest2.send(''); } </script> </head> <link rel="stylesheet" type"text/css" href="css/style.css" /> <body> <div id="choice"> <table> <tr> <td><u><a onMouseUp="loginRequest()">Click to Login</a></u> </td> </tr> <tr> <td><u><a onMouseUp="registerRequest()">Click to Register</a></u> </td> </tr> </table> </div> <div id="cell"> <div id="content"> <?php include "login_form.php"; ?> </div> </div> </body>
Thanks for your time guys.
Chris
Comment