开发者

AJAX XMLHttpRequest issues

开发者 https://www.devze.com 2023-03-17 12:00 出处:网络
I\'m using the geolocation API to get the user\'s co-ordinates, which I want to save as a variable in PHP and for argument\'s sake print on the same page (without refresh).

I'm using the geolocation API to get the user's co-ordinates, which I want to save as a variable in PHP and for argument's sake print on the same page (without refresh).

I'm using AJAX to send two JS variables from and index page to an external PHP page (which I haven't quite sorted yet but hopefully your answers will give me a better understanding of this).

In this PHP file, these two variables are inserted into the URL for an API which then prints out the town the user is in.开发者_运维问答

My question is: how do I echo this back to the original index page?


The PHP file should just echo the variable required, and the AJAX call should have access to this in the responseText.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号