好的,所以我从wamp本地服务器上读到了这个txt文件,
我对此文本进行了更改,并尝试将其发送回文件
ajax请求触发成功函数但文件没有改变,有什么想法吗?感谢
代码:
var customCss = "";
var customCssPath = "http://localhost:8081/userThemer/styles/custom.css";
var newStyle ="newwww";
$.ajax({
type: 'POST',
url: customCssPath,//url of receiver file on server
data: newStyle, //your data
success: function () {
console.log("YAY !");
},
error: function () {
console.log(":'(");
},
dataType: "text" //text/json...
});
答案 0 :(得分:1)
success: function (data) {
console.log(data);
console.log("YAY !");
},
请尝试这种方式。您可以获取数据。
答案 1 :(得分:0)
只需了解 $.ajax :
$.ajax({
url: 'xyz.php', // url of receiver file on server
type: 'POST', // send method, either POST or GET
data: data, // data to be sent to $url
dataType: 'text', // tells what kind of respnse you get
success: function ( response ) { // success call with response
console.log("WOW! your respnose is" + response );
},
error: function () { // error
console.log("ERROR Occured!!");
}
});
<强>更新强>
在您的接收文件中(我提到 xyz.php ),echo
您想要的回复如下:
<?php
echo 'this is a response from xyz.php file';
?>