I want to dynamically create a xml file using jquery or javascript and i don't want to download it. I want to assign it to the upload control. Then on button click i want to send it to the controller. How can i able to do that using jquery. Any help is appreciated.
-
Is controller you mantioned. Do you means server?Lupus– Lupus2013-05-10 08:25:36 +00:00Commented May 10, 2013 at 8:25
-
Yah server. I want to download it in the serverJonathan– Jonathan2013-05-10 08:27:00 +00:00Commented May 10, 2013 at 8:27
-
You can assign $.ajax({ dataType: 'xml', }) to your buttonLupus– Lupus2013-05-10 08:28:29 +00:00Commented May 10, 2013 at 8:28
-
how can i dynamically create an xml file. And i want to send the created file. That's what you are saying right?Jonathan– Jonathan2013-05-10 08:29:31 +00:00Commented May 10, 2013 at 8:29
-
actually I didnt realy get the question. Do you want to save this dinamicly created xml file to the yousers computer and than upload to the server?Lupus– Lupus2013-05-10 08:30:31 +00:00Commented May 10, 2013 at 8:30
|
Show 1 more comment
1 Answer
You can't send a xml file generated by JS in the client side because what you will have is not a file is just a string. But you can send the string to the server using the jquery post function (http://api.jquery.com/jQuery.post/). So create your valid XML string:
var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>" +
"<root>" + getXML() + "</root>"
And send it to the server:
$.post('test.html',{ data : xml }, function(data) {
$('.result').html(data);
});
Hope it helps ;)
1 Comment
Lupus
Yes this is the way if your question is that :)