tags:

views:

26

answers:

2

I'm studying Web Applications at university, and at the moment we have an assignment: build a 'blog' using only CSS, Javascript and XML. We have to store the blog posts in a .xml file, which is what's got me stuck at the moment.

So, essentially I need to be able to write a Javascript function which writes to a server-side file. There are so many better ways to do this but we literally have to do it in Javascript. The teacher is totally unhelpful and everyone I asked thinks it can't be done.

I don't want anyone doing my work for me or anything, just it'd be nice to know how to do this, if it's even possible.

Cheers in advance.

A: 

If you are talking about JavaScript running in a browser, then you have to write some JavaScript that makes an HTTP request (possibly using XMLHttpRequest) to a server side process that will write the file. The client can't write directly to the server's filesystem.

If you are talking about JavaScript running on the server, then it depends on your JavaScript environment. There are lots of different ones: http://en.wikipedia.org/wiki/Server-side_JavaScript

David Dorward
A: 

really hard homework, you can not find it done via google :)

this must take more than a weekend... is this a term homework?

i think it would be better if your teacher lets you to use ajax requests to an other server side language. (maybe asp.net - ashx file which writes your xmls.)

serdar
Yeah, it's building off another assignment from a few weeks ago. We have another 2 weeks to complete it. I'm not familiar with ASP so I'm trying to convince my teacher to allow us to use PHP. Thanks :)
Steve