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: - <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>
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.overrideMimeType('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
3 1594
hi,
There is nothing wrong with using two function on the same page.
I've used more than that with my project so i dont think its a problem. Your problem is somewhere else as i think......
Regards,
RP
Thanks, i thought as much, i will keep trying to figure it out myself.
Why are you 'closing' the request on line 40?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: GTi |
last post by:
I have a ASP 2.0 page where I use some Ajax code. The Ajax code
(JavaScript) is inserted from CodeBehind.
In my page I have a submit button and some links for Ajax functions.
When I load the page...
|
by: Frances |
last post by:
I literally started learning AJAX just last weekend.. I have this page,
http://www.francesdelrio.com/ajax/db2.html, where I'm essentially doing
what's here,...
|
by: Seguros Catatumbo |
last post by:
Hi guys, i am having some weird issue with an ajax page.
I am designing a simple ajax calendar, because the one over yahoo is
about 200kb long, and mine is 9kb and really simple.
I am using...
|
by: Martin |
last post by:
Hello NG,
I've been doing some AJAX for a few weeks now. The basics worked fine so
far, but now I've got the following problem which I can't solve:
With AJAX you typically update/replace only...
|
by: Sandman |
last post by:
So, I've used ajax for quite some time for different stuff. Mostly I
just feed a funktion I made with the ID of the DIV that should be
updated with the output from page XXX.php
Now I want to...
|
by: shivendravikramsingh |
last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
|
by: =?Utf-8?B?RGFuaQ==?= |
last post by:
Hi,
Trying to create a master page that holds a menu, and the menu switches
between pages in the site. 2 problem arrosed:
a. When I navigate from page to page (all AJAX Web Forms, with the...
|
by: John Straumann |
last post by:
Hello all:
I am a CRM Solution Architect so not a .NET expert by any means. I am
working with a customer who needs to modify the Advanced find in CRM which
works as shown here:
...
|
by: knkk |
last post by:
Instead of an id getting its innerHTML changed, the entire page is getting refreshed with this function of mine (you may want to look just at the end of the function where there's an alert):
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |