0
我是學習php和jQuery的新手,我自己嘗試了很多次,但也不太好。如何將PHP json_decode修改爲jquery.getJSON()?
如何將PHP json_decode修改爲jQuery.getJSON()?我想修改所有的PHP代碼到JavaScript。
$json_data = file_get_contents("data.txt");
$data = json_decode($json_data, true);
if($data){
$num = 1;
foreach ($data as $result) {
?>
$.ajax({
url: "page2.php",
dataType: "html",
type: 'POST',
data: "value=<?php echo $result['name']; ?>",
success: function(data){
$("#result<?php echo $num; ?>").html(data);
}
<?php
$num++
}
}
?>
JSON樹:
[
{"name" : "name1"},
{"name" : "name2"},
{"name" : "name3"},
]