url : 섹션의 jquery 스크립트에 $ data 변수를 보내어 다른 PHP 파일에서 소스를 가져올 수 있습니까? (초보자 프로그래머). 내가 예를 들어 같은 것을 할 수 있어야합니다 :JQUERY - PHP 변수를 저장하고 jquery 스크립트에 에코?
var source =
{
datatype: "json",
datafields: [
{ name: 'timeserver', type: 'time'},
{ name: 'val1', type: 'number'},
],
url: '<?php echo $data; ?>.php',
cache: false
};
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="jqwidgets/jqxchart.js"></script>
<script type="text/javascript" src="jqwidgets/jqxdata.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// prepare the data
var theme = 'classic';
var source =
{
datatype: "json",
datafields: [
{ name: 'timeserver', type: 'time'},
{ name: 'val1', type: 'number'},
],
url: 'data.php',
cache: false
};
var dataAdapter = new $.jqx.dataAdapter(source,
{
autoBind: true,
async: false,
downloadComplete: function() { },
loadComplete: function() { },
loadError: function() { }
});
// prepare jqxChart settings
var settings = {
title: "Temperatura",
showLegend: true,
padding: { left: 5, top: 5, right: 5, bottom: 5 },
titlePadding: { left: 90, top: 0, right: 0, bottom: 10 },
source: dataAdapter,
categoryAxis:
{
text: 'Category Axis',
textRotationAngle: 0,
dataField: 'timeserver',
formatFunction: function (value) {
return $.jqx.dataFormat.formatdate(value, 'HH:mm:ss');
},
showTickMarks: true,
tickMarksInterval: Math.round(dataAdapter.records.length/6),
tickMarksColor: '#888888',
unitInterval: Math.round(dataAdapter.records.length/6),
showGridLines: true,
gridLinesInterval: Math.round(dataAdapter.records.length/3),
gridLinesColor: '#888888',
axisSize: 'auto'
},
colorScheme: 'scheme05',
seriesGroups:
[
{
type: 'line',
valueAxis:
{
displayValueAxis: true,
description: 'Temperatura',
//descriptionClass: 'css-class-name',
axisSize: 'auto',
tickMarksColor: '#888888',
unitInterval: 5,
minValue: 10,
maxValue: 50
},
series: [
{ dataField: 'val1', displayText: 'Temperatura' }
]
}
]
};
// setup the chart
$('#jqxChart').jqxChart(settings);
});
</script>
<style type="text/css">
</style>
</head>
<body class='default'>
<!-- <div class="flip3D">
<div class="back">-->
<div style="width:670px; height:400px" id="jqxChart">
</div>
<!--</div>
<div class="front"><div style="width:670px; height:400px" id="jqxChart"></div></div>
</div> -->
<div class="flip3D">
<?php
// define variables and set to empty values
$data = $data1h = $data24h = $data7zile = $data1luna = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$data = test_input($_POST["gender"]);
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<h2>Arhiva</h2>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Select:
<input type="radio" name="gender" value="data" >Curent
<input type="radio" name="gender" value="data1h" >Ultima ora
<input type="radio" name="gender" value="data24h" >Ultima zi
<input type="radio" name="gender" value="data7zile" >Ultima saptamana
<input type="radio" name="gender" value="data1luna" >Ultima luna
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
echo json_encode($data);
?>
</div>
</body>
당신은 브라우저에서 렌더링됩니다 페이지에 PHP 변수를 구문 분석 할 수 있습니다. – Daniel
정확히 어디서 문제가 있습니까? 좀 더 구체적으로 말하십시오 – rpax