質問編集履歴
1
少し変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,91 +1,3 @@
|
|
1
1
|
jqueryのajaxを使い、javascriptの変数をphpに渡して、新しいファイルを作りたいのですがうまくいきません。
|
2
2
|
|
3
3
|
どこで引っかかっているのか原因がわからないためどうしようもありません。アドバイスお願いします。
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
<html>
|
8
|
-
|
9
|
-
<head>
|
10
|
-
|
11
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
12
|
-
|
13
|
-
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
|
14
|
-
|
15
|
-
</head>
|
16
|
-
|
17
|
-
<body>
|
18
|
-
|
19
|
-
<button id="make">ファイル作成</button>
|
20
|
-
|
21
|
-
<div id="result"></div>
|
22
|
-
|
23
|
-
</body>
|
24
|
-
|
25
|
-
</html>
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
<script type="text/javascript">
|
30
|
-
|
31
|
-
$(function () {
|
32
|
-
|
33
|
-
$("#make").click(function(){
|
34
|
-
|
35
|
-
var abc = nwefile.txt;
|
36
|
-
|
37
|
-
$.ajax({
|
38
|
-
|
39
|
-
type: "POST",
|
40
|
-
|
41
|
-
url: "123.php",
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
success: function( ) {
|
46
|
-
|
47
|
-
$(data).load( "#abc" );
|
48
|
-
|
49
|
-
},
|
50
|
-
|
51
|
-
error: function( data ) {
|
52
|
-
|
53
|
-
$("#result").html( '<font color="red">エラー</font>' );
|
54
|
-
|
55
|
-
}});
|
56
|
-
|
57
|
-
)};
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
</script>
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
<?PHP
|
72
|
-
|
73
|
-
$fn = $_POST["data"];
|
74
|
-
|
75
|
-
$file_name = "$fn"; // 作成するファイル名の指定
|
76
|
-
|
77
|
-
if( !file_exists($file_name) ){ // ファイルの存在確認
|
78
|
-
|
79
|
-
touch( $file_name ); // ファイル作成
|
80
|
-
|
81
|
-
}else{
|
82
|
-
|
83
|
-
echo('Warning - ファイルが存在しています。 file name:['.$file_name.']');
|
84
|
-
|
85
|
-
exit();
|
86
|
-
|
87
|
-
}
|
88
|
-
|
89
|
-
echo('Info - ファイル作成完了。 file name:['.$file_name.']');
|
90
|
-
|
91
|
-
?>
|