Passing array through AJAX from php to javascript

前端 未结 3 1635
青春惊慌失措
青春惊慌失措 2021-01-20 02:26

I need to get an array generated from a script php. I have Latitude and Longitude for each user in a database. I take the values from the db with this code (file.php):

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-20 02:46

    use this

    echo json_encode($array);
    

    on server side

    and

    var arr=JSON.parse(result);
    

    on client side

提交回复
热议问题