รบกวนช่วยหน่อยครับ ดึงchart จากไฟล์ B.php มาแสดงในไฟล์ A.php

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา รบกวนช่วยหน่อยครับ ดึงchart จากไฟล์ B.php มาแสดงในไฟล์ A.php

รบกวนช่วยหน่อยครับ ดึงchart จากไฟล์ B.php มาแสดงในไฟล์ A.php
เนื่องจากผมไม่มีพื้นฐานจาวาสคริ้ป ajax หรือ jquery น่ะครับ รบกวนหน่อยนะครับ #ขอบคุณครับ


Sornram 08-04-2017 18:06:50

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
  แนะนำไม่ถูกเหมือนกัน


ninenik 08-04-2017
 ความคิดเห็นที่ 2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
ไฟล์ A.php
 
<div class="panel-body">
  <form action="">
       <select name="customers" onchange="showCustomer(this.value)">
            <option value="">เลือกปี</option>
            <option value="2016">2016</option>
            <option value="2017">2017</option>
        </select>
   </form>
<br>
<div id="txtHint">Customer info will be listed here...</div>
</div>
 
 
<script>
function showCustomer(str) {
  var xhttp;   
  if (str == "") {
    document.getElementById("txtHint").innerHTML = "";
    return;
  }
  xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("txtHint").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "B.php" str, true);
  xhttp.send();
 
}
</script>


sornram 08-04-2017 21:25
 ความคิดเห็นที่ 3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
ไฟล์ B.php
 
<!DOCTYPE HTML>
<html>
 
<head>
<title>CanvasJS Chart jQuery Plugin</title>
<script type="text/javascript" src="http://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="http://canvasjs.com/assets/script/jquery.canvasjs.min.js"></script>
<script type="text/javascript">
window.onload = function () {
 
//Better to construct options first and then pass it as a parameter
    var options = {
        title: {
            text: "Column Chart using jQuery Plugin"
        },
                animationEnabled: true,
        data: [
        {
            type: "column", //change it to line, area, bar, pie, etc
            dataPoints: [
                { x: 10, y: 10 },
                { x: 20, y: 11 },
                { x: 30, y: 14 },
                { x: 40, y: 16 },
                { x: 50, y: 19 },
                { x: 60, y: 15 },
                { x: 70, y: 12 },
                { x: 80, y: 10 }
            ]
        }
        ]
    };
 
    $("#chartContainer").CanvasJSChart(options);
 
}
</script>
</head>
<body>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
</body>
 
</html>


sornram 08-04-2017 21:29
 ความคิดเห็นที่ 4
  น่าจะใช้เป็น iframe แทน ลองดูเนื้อหานี้เป็แนวทาง

ขยายขนาดความสูงของ iframe ตามความสูงของเพจที่แสดง ด้วย jQuery 
https://www.ninenik.com/content.php?arti_id=220 via @ninenik

หรือดูเกี่ยวกับ iframe คลิก

หรือไม่ก็แสดงในไฟล์ A.php แล้ว โดยใช้ ajax เปลี่ยนข้อมูลที่นำมาใช้ แล้ว แสดง chart ตามข้อมูลใหม่


ninenik 08-04-2017
1






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ