在這個html頁面中,我在php頁面發送變量fin的值(http://sat3.altervista.org/index.php?valore=「+ fin)。在這個php頁面中,我嘗試了變量的值,但我沒有成功,有人能幫助我在jQuery函數中發送一個php頁面的值
<!doctype html>
<html>
<head>
<title>Parsing</title>
<script type="text/javascript" src="jquery-2.1.0.min.js"></script>
</head>
<script>
var fin = "SAT000000002575";
url = "http://sat3.altervista.org/index.php?valore="+ fin,
data = {
get_param: 'value'
};
$.getJSON(url, data, function (data) {
for (var i = 0; i < data.length; i++) {
var lin = data[i]["Nr SAT"];
$('body').append($('<p>').html('Numero Sat: <a href ="http://sat3.altervista.org/NuovoFile.html?id=' + lin + '">' + data[i]["Nr SAT"] + '</a>'));
$('body').append($('<p>').html('Data Apertura: ' + data[i]["Data Apertura"]));
}
});
</script>
<body>
<header>
</header>
</body>
</html>
這是PHP頁面:?
<?php
// Sopprimo gli errori del php
error_reporting(0);
// Includo la libreria
require_once 'excel_reader2.php';
$file_handle = fopen("leggimi2.csv", "r");
//EDIT: Define an array to hold individual lines
$data = array();
while (!feof($file_handle)) {
//HERE I TAKE THE VALUE BUT IT DON'T CONTAIN NOTHING
$myValue = $_GET["valore"];
$line_of_text = fgetcsv($file_handle, 1024);
if ($line_of_text[0] == $myValue)
{
$arr = array('Nr SAT' => $line_of_text[0],'Data Apertura' => $line_of_text[13], 'Tipo Servizio' => $line_of_text[1], 'Stato SAT' => $line_of_text[2],'Marca Terminale' => $line_of_text[4], 'Modello Terminale' => $line_of_text[5], 'IMEI guasto' => $line_of_text[6],'IMEI consegnato' => $line_of_text[7],'Famiglia guasto' => $line_of_text[8],'Descrizione guasto' => $line_of_text[9]);
//EDIT: Add the line to the array
$data[] = $arr;
}
}
//EDIT: Encode the array as a JSON array of line objects
echo json_encode($data);
//$myValue = isset($_GET['myValue']) ? $_GET['myValue'] : '';
fclose($file_handle);
?>
失敗的地方?有什麼答案?查詢發送正確嗎?請提供我們能夠幫助您的信息。我建議使用Firebug或Chrome調試器來幫助你自己或提供所需的信息。 –
php代碼在哪裏? –
我添加了php頁面。我認爲php頁面中的值不會出現。幫我 !! – user3628914