teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

2019/11/27 03:28

投稿

nikuniku12
nikuniku12

スコア14

title CHANGED
File without changes
body CHANGED
@@ -1,44 +1,6 @@
1
1
  idをphpに送信しそのidと等しいデータを削除しjs側で表示させたいのですが、txtファイルから削除したにも関わらずデータがなぜかずっと表示されます。何故だかわかりませんか?
2
2
 
3
- ```javascript
4
- $(function(){
5
- $("#send").on('click',function(){
6
- var ary_data = {};
7
- ary_data.userid = $('input[name="id"]').val();
8
- send_data=JSON.stringify(ary_data);
9
- $.ajax({
10
- type:"DELETE",
11
- url:"send.php",
12
- contentType: "Content-Type: application/json; charset=UTF-8",
13
- dataType : "json",
14
- data:send_data,
15
- }).done(function(data){
16
- data.forEach(function(x){
17
- Object.entries(x).forEach(y=>{
18
- $("#res").append('キー:'+y[0]+' :値:' +y[1]+"<br/>");
19
- });
20
- });
21
- }).fail(function(XMLHttpRequest, textStatus, errorThrown){
22
- alert(errorThrown);
23
- });
24
- });
25
- });
26
3
 
27
- <table>
28
- <tr>
29
-
30
- <th>ID:</th>
31
- <th><input type="text" id="id" name="id" maxlength="100" value=""></th>
32
- <th><button id="send" type="button">send</button>
33
- </th>
34
- </tr>
35
- </table>
36
- </form>
37
- </section>
38
- <div id="res"></div>
39
-
40
- ```
41
-
42
4
  ```php
43
5
  <?php
44
6
  $json = file_get_contents("php://input");

2

2019/11/27 03:28

投稿

nikuniku12
nikuniku12

スコア14

title CHANGED
File without changes
body CHANGED
@@ -57,11 +57,11 @@
57
57
  $newLines[] = $val;
58
58
  }
59
59
  }
60
- $fp = fopen("json12.txt", "w");
60
+ $fp = fopen("product.txt", "w");
61
61
  fwrite($fp, implode("\r", $newLines));
62
62
  fclose($fp);
63
63
 
64
- $fp=fopen("json12.txt","r");
64
+ $fp=fopen("product.txt","r");
65
65
  while(($data=fgetcsv($fp,1024))!==false){
66
66
  $tmp=&$datas[];
67
67
  foreach($data as $x){

1

タグのついか

2019/11/27 02:51

投稿

nikuniku12
nikuniku12

スコア14

title CHANGED
File without changes
body CHANGED
File without changes