473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to write to a .txt file with Ajax Request?

hi every body

i want to upload file using Ajax ,i have try to use this code bellow ,but it's not work (i can't write helloworld in text1.txt).Du you no what is a problem ??me i configure anithing before it works ??PLEASE help me with some code .


Code:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>javascript-only file writing</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <script type="text/javascript" src="bajax.js"></script>
  7.  
  8. <script type='text/javascript'>
  9. var fileName= "text1.txt";
  10. var data= "hello world";
  11.  
  12. function IO(U, V) { // A tiny ajax library. by DanDavis
  13. var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
  14. X.open(V ? 'PUT' : 'GET', U, !1);
  15. X.setRequestHeader('Content-Type', 'text/html')
  16. X.send(V ? V : '');
  17. //return alert("resp: "+X.responseText);
  18. return X.responseText;
  19. }
  20.  
  21. // +++++++ customize code below ++++++++
  22.  
  23. function test(){
  24. alert("Data ist : "+data);
  25. IO( fileName, data ); //save it
  26. alert(" Data geschrieben in :" + fileName);
  27. //alert(IO( fileName )); //check the file
  28.  
  29. }
  30. </script>
  31. </head>
  32.  
  33. <body onload = "test()" >
  34.  
  35. </body>
  36. </html>
thank u in advance
Jan 31 '11 #1

✓ answered by Dormilich

the PUT method is usually deactivated on public servers (at least on all hosts I have come across), otherwise everyone could write to it. (I think PUT is disabled by default)

3 7313
Dormilich
8,658 Expert Mod 8TB
the PUT method is usually deactivated on public servers (at least on all hosts I have come across), otherwise everyone could write to it. (I think PUT is disabled by default)
Jan 31 '11 #2
Thank u for your Answer Dormilich,do u have any example how i can do that ? i have try to read a textfile but ,i can't write to it .Please when u any code or Idea how i can do that ,tel me please.

Thank u in Advance

Denis
Jan 31 '11 #3
Dormilich
8,658 Expert Mod 8TB
http://www.apacheweek.com/features/put
Feb 1 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: petermichaux | last post by:
Hi, Is it possible for an AJAX request to be left open for multiple responses? This could avoid repetitive polling of the server. Thanks, Peter
5
by: dougwig | last post by:
I'm trying to handle the scenario where a user's session times out and and their ajax request triggers a redirection by the webserver (302 error?). I'm using Prototype 1.4 and the my works great...
0
by: Mathan Babu | last post by:
Hello, Once the AJAX request is fired the readystate property remain as 1. It never gets changed and the callback method is not firing as a result the ..aspx page is not being rendered. The...
0
by: arunprabu | last post by:
Hi, I have a problecm with the AJAX request in my webpage. I have some filters on top of the page. I have a submit button and an empty div below the filters. Some of the filters have ajax...
3
by: Simon | last post by:
I have the following code in Javascript which is creating and sending an XMLHttpRequest . <code> var xmlHttp; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlHttp = new...
1
by: nikki.farrah | last post by:
Hi all, this is my first time posting so any help is appreciated! I am doing a simple AJAX request to our server, and I would like the cursor style changed to 'wait' when the user clicks a button...
7
by: Sebarry | last post by:
Hi, I have a Javascript function that creates an Ajax Request object in order to retrieve data from a database using a PHP script. The Javascript function is invoked by another Javascript function...
8
by: alejrb | last post by:
Hi! I have a pretty simple AJAX request that just GETs the content of a page depending on a name that is fed to it. I'm parsing the page in quite a complex way, so I'm using the DOM to make it a...
3
by: mentor | last post by:
When user is authenticated, the server store "UserName" in session. Then throug ajax, the user request another page which require authentication. How the ajax request tell the server that one has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.