こんにちはみんな普通じゃない:)!!
foo.php
<?php
if (isset($_POST['data']))
$stringData = $_POST['data'];
$file = "ciao.txt";
$fh = fopen($file, 'w') or die("can't open file");
fwrite($fh, $stringData);
fclose($fh);
?>
file.js
function WriteToFile() {
var dataa = "foo bar";
$.post("foo.php", {data: dataa}, function(result){ alert("ciaoooo!!");}
, "json");
}
これはエラーであり、file.txtに書き込むことができません
注意:未定義の変数:stringData
そういう機能もやってみました
function WriteToFile() {
var data = "foo bar";
$.ajax({
url: 'foo.php',
type: 'POST',
data: { 'data' : 'data'},
success: function() {
alert('the data was successfully sent to the server');
}
});
but the result is the same!! Anyone have some idea???