我有两个文件,请参考。
v1 / index.php(php)
function getuserDetails($request){
$userName= $request->getParam('name');
$mobile_no= $request->getParam('image');
$email= $request->getParam('email');
echo json_encode(array('status' => '1','msg'=>'success','data'=>"Name:-".$userName));
}
index.php(标题)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
var checkState = function(){
jQuery.ajax({
url: './v1/index.php'
}).done(function(datad){
var user_name = jQuery('#name');
var email = jQuery('#email');
user_name.html(datad.data);
email.html(datad.email);
});
}
checkState();
setInterval(checkState, 10000);
</script>
index.php(html)
Name:- <strong><span id="name"></span></strong>
我正在尝试使用JSON
从其他文件中获取名称,但它没有获取,也没有显示错误...
另请查看this comment,问题可能更清楚