Information Systems



How do you get input data to post using AJAX?

It's a matter of getting the select and input fields.

function escapeUrl(s)
{
// ? others
s = s.replace(/&/, "&apm;");
s = s.replace(/#/, "%23");
s = s.replace(/%/, "%25");
return s;
}
function save()
{
var inputs = document.getElementsByTagName("select");
var s = "";
for (i = 0; i < inputs.length; i++)
{
if (inputs[i] == null)
continue;
if (inputs[i].name == null)
continue;
if (inputs[i].name == "")
continue;
s += inputs[i].name + "=" + escapeUrl(inputs[i].value) + "&";
}
inputs = document.getElementsByTagName("input");
for (i = 0; i < inputs.length; i++)
{
if (inputs[i] == null)
continue;
if (inputs[i].name == null)
continue;
if (inputs[i].name == "")
continue;
s += inputs[i].name + "=" + escapeUrl(inputs[i].value) + "&";
}
post(s);
}