0

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.

6
  • Is controller you mantioned. Do you means server? Commented May 10, 2013 at 8:25
  • Yah server. I want to download it in the server Commented May 10, 2013 at 8:27
  • You can assign $.ajax({ dataType: 'xml', }) to your button Commented 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? Commented 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? Commented May 10, 2013 at 8:30

1 Answer 1

2

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 ;)

Sign up to request clarification or add additional context in comments.

1 Comment

Yes this is the way if your question is that :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.