質問編集履歴

3

console追加

2022/04/17 03:57

投稿

atushi
atushi

スコア5

test CHANGED
File without changes
test CHANGED
@@ -50,6 +50,7 @@
50
50
  data: { "id":id, "idd":idd},
51
51
  dataType : "json"
52
52
  }).done(function(data){
53
+ console.log(data) <!--console-->
53
54
  $("#res").text(data.id+' : '+data.name+' : '+data.hoge);
54
55
  }).fail(function(XMLHttpRequest, textStatus, error){
55
56
  alert(error);

2

画像を追加

2022/04/17 02:37

投稿

atushi
atushi

スコア5

test CHANGED
File without changes
test CHANGED
@@ -67,3 +67,6 @@
67
67
  私、PHPが初心者で申し訳ございません。
68
68
 
69
69
  PHP側でも、JSONを取得したいのですがお教えいただきたく存じます。
70
+
71
+ こちらconsoleのスクリーンショットになります。
72
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-04-17/e396455f-0517-4f83-85ae-024e0ee32e96.jpeg)

1

コードの掲載

2022/04/16 09:58

投稿

atushi
atushi

スコア5

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  [HTML側](https://office606.org/test/a.html)
8
8
 
9
- コード
9
+ コードPHP側
10
10
  ```
11
11
  <?php
12
12
  // 画面から送られたきた値
@@ -21,6 +21,47 @@
21
21
  exit;/* */
22
22
  ```
23
23
 
24
+ コードJavascript側
25
+ ```
26
+ <!DOCTYPE html>
27
+ <html>
28
+ <head>
29
+ <meta charset="utf-8">
30
+ <!-- jQueryの読み込み (これがないと動かないよ) -->
31
+ <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
32
+ <title>Ajax Sample1</title>
33
+ </head>
34
+ <body>
35
+ ID : <input type="text" id="id" />
36
+ ID : <input type="text" id="idd" />
37
+ <button id="btn">SEND</button>
38
+ <div><br></div>
39
+ <div id="res">戻り値が表示される</div>
40
+ <script>
41
+ $(function(){
42
+ // ボタンがクリックされたら
43
+ $("#btn").on("click", function(event){
44
+ // 入力されたID値を取得
45
+ id = $("#id").val();
46
+ idd = $("#idd").val();
47
+ $.ajax({
48
+ type: "POST",
49
+ url: "ajax.php",
50
+ data: { "id":id, "idd":idd},
51
+ dataType : "json"
52
+ }).done(function(data){
53
+ $("#res").text(data.id+' : '+data.name+' : '+data.hoge);
54
+ }).fail(function(XMLHttpRequest, textStatus, error){
55
+ alert(error);
56
+ });
57
+ });
58
+ });
59
+ </script>
60
+ </body>
61
+ </html>
62
+ ```
63
+
64
+
24
65
  ページ側では反映されているのでこちらどの様にしてPHP側の
25
66
  エンコード(NULL)を解消させるかお教えいただけないでしょうか?
26
67
  私、PHPが初心者で申し訳ございません。