473,569 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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
3 7344
Dormilich
8,658 Recognized Expert Moderator Expert
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
hubertdennis
2 New Member
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 Recognized Expert Moderator Expert
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
13166
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
20056
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 with Firefox,but with IE6 the onFailure never gets called and the request never completes. My code: var ajaxReq = new Ajax.Request( url,...
0
1709
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 two functions that is involved in the above mentioned issues are placed below: fn #1
0
1825
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 requests to update the content within the filters. For example, I have 2 drop downs, one for state and another for country. When I select a country in...
3
5339
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 ActiveXObject("Msxml2.XMLHTTP");
1
2976
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 which calls the function below. After the request is complete, I would like the style changed back. For some reason, it doesn't change the cursor...
7
14461
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 and should return to the caller only once the request is complete. Currently the function that creates the Ajax.Request object returns to the caller...
8
2977
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 bit easier. Having created my parser, I realised that document.getElementById() doesn't work (>.<), because I'm trying to use it on the AJAX...
3
2017
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 been authenticated, or how the server know it's from 'UserName"? Should ajax set SessionId in Header or Cookie ? How to get and set the SessionId ? ...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.