Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 php 文件,其中包含一些变量,如 $name1、$name2... 我如何使用 AJAX 在我的检查循环页面中接收这些值?
主循环页面。
<script type="text/javascript"> function checkdata ( ) { ....? } setTimeout ( "checkdata()", 3000 ); </script>
PHP 文件 (info.php)
<?php $name1=7; $name2=3; . . . ?>
PHP
$info['name1'] = 7; $info['name2'] = 3; echo json_encode($info);
JS
function checkData() { $.ajax({ url: "info.php", dataType: "JSON", success: function(info){ alert(info.name1); alert(info.name2); } }); }