I am new to AJAX. I want some help in passing large data to the server. Basically I have 100 text boxes in a form, I want to pass all this information to an asp or asp.net page, which will then process the data and respondes whether it was successfull or not.
I was thinking of creating a xml string using javascript and then sending it to the server, I am not sure if this is the right approach.
from my search I found that to pass huge data I need to use POST method, I tried it but looks like I am missing something. So it will be great help if somone could guide me or send me some working examples. In advance Thank you very much.
Thank you for your reply below is the code, can you please tell me where I am doing wrong??
AJAX.htm
<html>
<head>
<script src="Global.js" language="javascript"></script>
<script src="XMLWriter.js" language="javascript"></script>
<script language="javascript" type="text/javascript">
var url = "getdata.asp"; // The server-side script
function WriteTest()
{
try
{
var XML=new XMLWriter();
XML.BeginNode("Example");
XML.Attrib("SomeAttribute", "And Some Value");
XML.Attrib("AnotherAttrib", "...");
XML.WriteString("This is an example of the JS XML WriteString method.");
XML.Node("Name", "Value");
XML.BeginNode("SubNode");
XML.BeginNode("SubNode2");
XML.EndNode();
XML.BeginNode("SubNode3");
XML.WriteString("Blah blah.");
XML.EndNode();
XML.Close(); // Takes care of unended tags.
// The replace in the following line are only for making the XML look prettier in the textarea.
document.getElementById("ExampleOutput").value=XML.ToString().replace(/</g,"\n<");
}
catch(Err)
{
alert("Error: " + Err.description);
}
return false;
}
function handleHttpResponse()
{
if (http.readyState == 4) {
if (http.status == 200) {
// Use the XML DOM to unpack the city and state data
results = http.responseText
alert(results);
isWorking = false;
}
else {
alert("There was a problem retrieving the XML data:\n" + http.statusText);
}
}
}
function WriteForm(e)
{
try
{
var Frm=Settings.SrcElement(e);
var XML=new XMLWriter();
XML.BeginNode(Frm.name);
XML.Attrib("Example", "Attribute & Value");
var Nodes=Frm.elements;
for (var i=0;i<Nodes.length;i++)
XML.Node(Nodes[i].name, Nodes[i].value);
XML.EndNode();
XML.Close();
document.getElementById("ExampleOutput").value=XML.ToString().replace(/</g,"\n<");
var ExampleOutput = document.getElementById("ExampleOutput").value;
//var parameters = "ExampleOutput=" + ExampleOutput;
var parameters = "ExampleOutput=Test";
Can you please edit your post to add code tags as I told you in my first post? It makes the reading much simpler. I will review it when I get the time. Maybe someone else will beat me to it.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
<html>
<head>
<script src="Global.js" language="javascript"></script>
<script src="XMLWriter.js" language="javascript"></script>
<script language="javascript" type="text/javascript">
var url = "getdata.asp"; // The server-side script
function WriteTest()
{
try
{
var XML=new XMLWriter();
XML.BeginNode("Example");
XML.Attrib("SomeAttribute", "And Some Value");
XML.Attrib("AnotherAttrib", "...");
XML.WriteString("This is an example of the JS XML WriteString method.");
XML.Node("Name", "Value");
XML.BeginNode("SubNode");
XML.BeginNode("SubNode2");
XML.EndNode();
XML.BeginNode("SubNode3");
XML.WriteString("Blah blah.");
XML.EndNode();
XML.Close(); // Takes care of unended tags.
// The replace in the following line are only for making the XML look prettier in the textarea.
document.getElementById("ExampleOutput").value=XML.ToString().replace(/</g,"\n<");
}
catch(Err)
{
alert("Error: " + Err.description);
}
return false;
}
function handleHttpResponse()
{
if (http.readyState == 4) {
if (http.status == 200) {
// Use the XML DOM to unpack the city and state data
results = http.responseText
alert(results);
isWorking = false;
}
else {
alert("There was a problem retrieving the XML data:\n" + http.statusText);
}
}
}
function WriteForm(e)
{
try
{
var Frm=Settings.SrcElement(e);
var XML=new XMLWriter();
XML.BeginNode(Frm.name);
XML.Attrib("Example", "Attribute & Value");
var Nodes=Frm.elements;
for (var i=0;i<Nodes.length;i++)
XML.Node(Nodes[i].name, Nodes[i].value);
XML.EndNode();
XML.Close();
Bookmarks