-
AJAX form tag problem
So i've got this simple ajax page: buttons across the top, and a div down below which displays different content depending on what button you press. I want this to be able to interact with a MySQL database i've got so I've got forms and php and whatever but that's not the problem. The problem is that whenever i have a form tag in the code i'm passing to getElementbyID, it doesnt pass anything. I know the code is at least getting to that point in the script, as the alert the line above displays the code i want, but somehow that doesnt get passed to the getElementbyID. Any suggestions?
function makeRequest(url) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/php');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Giving up Cannot create an XMLHTTP instance');
return false;
}
http_request.open('GET', url, true);
http_request.onreadystatechange = alertContents;
http_request.send(null);
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
alert(http_request.responseText);
document.getElementById('maintext').innerHTML=http_request.responseText;
} else {
alert('There was a problem with the request.');
}
}
}
/*And here's the HTML that should be passing the code*/
<td class="back">
<div class="topbar" width="auto" onclick="makeRequest('edit_act.php')">
<center>Edit Activity</center>
</div>
</td>
/*and here's the code it should be posting, edit_act.html*/
<table>
<form action="add_act.php" method="post"> /*if i delete this form tag, the page displays properly, but then i can't post the info in the form to the database. add_act.php is just a script that posts the info to the database*/
<tr>
<td>Location:</td>
<td><input type="text" name="location" tabindex="1"></td>
<td>Date:</td>
<td><input type="text" name="date" tabindex="2"></td>
</tr>
<tr>
<td>Duration(Nights):</td>
<td><input type="text" name="duration" tabindex="3"></td>
<td>Description:</td>
<td><input type="text" name="description" tabindex="4"></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Add this Activity" tabindex="18" accesskey="enter"></td>
<td><input type="reset" name="reset" value="Start over" accesskey="escape"></td>
</tr>
</form>
</table>
Similar Threads
-
By eldiener in forum .NET
Replies: 0
Last Post: 01-17-2007, 10:38 PM
-
Replies: 0
Last Post: 01-12-2007, 01:57 AM
-
By LucyG in forum ASP.NET
Replies: 1
Last Post: 02-09-2002, 07:45 PM
-
Replies: 1
Last Post: 09-30-2000, 07:47 AM
-
By Barend Esterhuizen in forum VB Classic
Replies: 0
Last Post: 05-04-2000, 01:55 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks