The function "Handler()" generates my post string, in the alert all appears well, however The server does not receive post! the response text which is generated via "var_dump($_POST['Entry']);" is "NULL"...
Anybody got a clue?
Code:
function Handler(Button,Msg)
{
var FormData = "";
if (Msg)
{
var DoIt=confirm(Msg)
if (DoIt==true)
{
try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { alert("Error: Could not load page.");}
Column = 0
while (Column <= Columns)
{
switch (document.getElementById(Title[Column]).tagName)
{
case "DIV":
if (document.getElementById(Title[Column]).innerHTML>"")
{
FormData = FormData + Title[Column] + "=" + escape(document.getElementById(Title[Column]).innerHTML) + "&";
}
break;
case "INPUT":
if (document.getElementById(Title[Column]).value>"")
{
FormData = FormData + "Entry["+(Column-OffSet)+"]=" + escape(document.getElementById(Title[Column]).value) + "&";
}
break;
case "TEXTAREA":
if (document.getElementById(Title[Column]).innerHTML>"")
{
FormData = FormData + "Entry["+(Column-OffSet)+"]=" + escape(document.getElementById(Title[Column]).innerHTML) + "&";
break;
}
}
Column = Column + 1;
}
FormData = FormData + "Button=" + Button + "&Sender=" + document.getElementById("Sender").value;
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4)
{
alert(xmlhttp.responseText);
}
}
alert(FormData)
xmlhttp.open("POST","Handler.php?"+FormData,true);
xmlhttp.send(null);
return false;
}
}
}
Ajax handler code:
PHP Code:
<?php require_once('../Connections/Hawks.php'); mysql_select_db($database_Hawks, $Hawks); var_dump($_POST['Entry']); switch ($_POST['Button']) { case "Save": $SQL="Show Columns From ".$_POST['Sender']; $ColumnTitles = mysql_query($SQL) or die("Could not connect Column Titles: " . mysql_error()); while ($Title = mysql_fetch_assoc($ColumnTitles)) { $i++; $SQL = "Update ".$_POST['Sender']." Set ".$Title[Field]."='".$_POST['Entry'][$i]."' Where ".$_POST['Sender']."ID = '".$_POST['Sender']."ID'"; echo ("Hello ".$_POST['Button'].", ".$SQL); //mysql_query($SQL); } break; case "Delete": $SQL = ""; break; } ?>
This is the alert value for FormData:
ClientsID=1&Entry[0]=14&Entry[1]=Friday&Entry[2]=Handy%20Foods%20%236161&Entry[3]=9308%20Balm%20Riverview%20Rd.&Entry[4]=Riverview&Entry[5]=FL&Entry[7]=%28813%29%20677-7294&Button=Save&Sender=Clients
Hence the post string "Handler.php?ClientsID=1&Entry[0]=14&Entry[1]=Friday&Entry[2]=Handy%20Foods%20%236161&Entry[3]=9308%20Balm%20Riverview%20Rd.&Entry[4]=Riverview&Entry[5]=FL&Entry[7]=%28813%29%20677-7294&Button=Save&Sender=Clients"
I have substituted "Get" and the address bar reflects this string.
The purpose of all this is that it will populate a preconstructed form and allow navigation and editing of the corresponding database. without changes needed to accomodate either. I should be able to break this up into discrete scripts and use them for the other forms and databases in the site.
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Last edited by Sleeping Troll; 04-12-2009 at 08:46 AM..
|