Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have dynamically created a xml string form a JSON object returned from server. I need to give the user to download this as a file so that when the user click the button named export he/she receives a downloadable.xml file and can be save d on local machine.

Is this possible?

-- Mithun Sreedharan

share|improve this question

2 Answers

up vote 2 down vote accepted

Have you generated the file on the server or on the client?

If you have generated the file at the server you can use the content-disposition header. You also need to set the content type to application/xml or text/xml.

If you have generated the file using jQuery, then it isn't possible for the user to save it locally. Javascript isn't allowed access to the file system.

share|improve this answer
Yes, i have generated the xml string on the client using jQuery, and i want when the user clicks a button, he will be prompted to save the xml as a file and user chooses the location. – Mithun Nov 2 '09 at 9:12
As I've said this is not possible with javascript. You need to consider an alternative solution. Like when user clicks a button the xml is Ajax posted to a server location, the server gets the xml and returns it as an attachment. – kgiannakakis Nov 2 '09 at 9:36

I was recently looking for something similar, and came across Downloadify. It appears to use a feature of Flash 10 to work around the filesystem limitation of JavaScript.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.