js ajax读取 写入
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>js中的Ajax经典实例</title>
<script type="text/javascript" >
function ajax() {
//1.声明异步请求对象:
var xmlHttp = null;
if (window.ActiveXObject) {
// IE6, IE5 浏览器执行代码
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
// IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
xmlHttp = new XMLHttpRequest();
}
//2.如果实例化成功,就调用open()方法:
if (xmlHttp != null) {
xmlHttp.open("get", "songs.txt", true);
xmlHttp.send();
xmlHttp.onreadystatechange = doResult; //设置回调函数
}
function doResult() {
if (xmlHttp.readyState == 4) { //4表示执行完成
if (xmlHttp.status == 200) { //200表示执行成功
document.getElementById("resText").innerHTML = xmlHttp.responseText;
}
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="resText"></div>
<input type="button" value="点击获得文本内容" onclick="ajax();"/>
</form>
</body>
</html>
js写入:https://blog.csdn.net/zhengyikuangge/article/details/72848789
https://www.cnblogs.com/eedc/p/6057391.html
java 部份参考大神:https://blog.csdn.net/milletguo/article/details/80144290
https://www.cnblogs.com/fulucky/p/9636090.html
https://blog.csdn.net/qq_23974323/article/details/80003815
https://blog.csdn.net/sinat_22797429/article/details/53118365
https://blog.csdn.net/qq78442761/article/details/79063901
写入:
File file =new File(request.getSession().getServletContext().getRealPath("/")+"js/system/read.txt");
Writer out =new FileWriter(file);
String data=privateString;
out.write(data);
out.close();
java 获取路径的各种方法:https://www.cnblogs.com/guoyuqiangf8/p/3506768.html
这篇博客汇总了使用JavaScript的AJAX技术读取和写入TXT文件的方法,并提供了多个参考链接,同时介绍了Java读取和操作TXT文件的不同途径。

1295

被折叠的 条评论
为什么被折叠?



