How to receive the xml file from client-side(javascript,i usejQuery)?

J

JUN

Sends an xml document as data to the server. By setting the
processData option to false, the automatic conversion of data to
strings is prevented.

code from jQuery documentation

var xmlDocument = [create xml document];
$.ajax({
url: "save.aspx",
processData: false,
data: xmlDocument,
success: handleResponse
});

Now,in server script, how do i read the xmlDocument and save a file.my
code like this,but it can't work.

private void Page_Load(object sender, System.EventArgs e){
Stream stream = Request.InputStream;
XmlDocument doc = new XmlDocument();
try
{
doc.Load(stream); // it will goto catch
doc.Save(Server.MapPath("bbbbbbbbbbbbbbbbbbbbb.xml"));
}
catch
{
}

}

Thanks a lot. it's very urgent.
 
J

Joe Fawcett

JUN said:
Sends an xml document as data to the server. By setting the
processData option to false, the automatic conversion of data to
strings is prevented.

code from jQuery documentation

var xmlDocument = [create xml document];
$.ajax({
url: "save.aspx",
processData: false,
data: xmlDocument,
success: handleResponse
});

Now,in server script, how do i read the xmlDocument and save a file.my
code like this,but it can't work.

private void Page_Load(object sender, System.EventArgs e){
Stream stream = Request.InputStream;
XmlDocument doc = new XmlDocument();
try
{
doc.Load(stream); // it will goto catch
doc.Save(Server.MapPath("bbbbbbbbbbbbbbbbbbbbb.xml"));
}
catch
{
}

}

Thanks a lot. it's very urgent.
I haven't used jQuery but what does the raw data actually look like?
 
J

JUN

Sends an xml document as data to the server. By setting the
processData option to false, the automatic conversion of data to
strings is prevented.
code from jQuery documentation
var xmlDocument = [create xml document];
$.ajax({
url: "save.aspx",
processData: false,
data: xmlDocument,
success: handleResponse
});
Now,in server script, how do i read the xmlDocument and save a file.my
code like this,but it can't work.
private void Page_Load(object sender, System.EventArgs e){
Stream stream = Request.InputStream;
XmlDocument doc = new XmlDocument();
try
{
doc.Load(stream); // it will goto catch
doc.Save(Server.MapPath("bbbbbbbbbbbbbbbbbbbbb.xml"));
}
catch
{
}

Thanks a lot. it's very urgent.

I haven't used jQuery but what does the raw data actually look like?

i use a activex to generate a xml document, then send it to server.

1. first, i use a object procedure to return xml document

XmlDocument result = new XmlDocument();
XmlDeclaration dec = result.CreateXmlDeclaration("1.0", "GB2312",
null);
result.AppendChild(dec);
XmlElement root = result.CreateElement("HELLO");
result.AppendChild(root);

2. javascript code:

var doc = OBJECT.SaveToDocument();

$.ajax({
url: "SaveToFile.aspx",
processData: false,
data:doc,
success: handleResponse
});

function handleResponse(){
alert("File Saved!");
};

i hope you can understand what i said. thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,039
Messages
2,570,376
Members
47,028
Latest member
IsmaelLans

Latest Threads

Top