我如何通过Javascript调用php函数 [英] haw can i call php function through Javascript

查看:94
本文介绍了我如何通过Javascript调用php函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人
我想制作一个页面来查找特定位置的经度和纬度,我在php页面上使用google Api进行计算:

Dear All
i want to make a page to find Longitude and Latitude of particular place i use google Api on php page for calculate it:

function getLongitude($place)
       {
          $urlc="http://maps.google.com/maps/api/geocode/json?address=".$place."&sensor=false";
          $geocode=file_get_contents($urlc);
	  $output= json_decode($geocode);
	
	$longitude = $output->results[0]->geometry->location->lng;
       return $longitude;
       }
finction getLatitude($place)
        {
        $urlc="http://maps.google.com/maps/api/geocode/json?address=".$place."&sensor=false";
       $geocode=file_get_contents($urlc);
	$output= json_decode($geocode);
	$latitude = $output->results[0]->geometry->location->lat;
        return $latitude;
	}


在按钮上的click事件上,我想调用Java脚本的calculate()


on the click event on button i want to call calculate()of java script

<script Languge="JavaScript>
function calculate()
 {
   var place= document.zodiac.PlaceOfBirth.value;
   document.zodiac.latitude.value= getLatitude(place)// call php function
   document.zodiac.latitude.value= getLatitude(place)//call php function
}
</script>


请帮助我可以在Java脚本中使用php函数.


kindly help haw can i use php function in java script.

推荐答案

place) {
place) {


urlc = " .


place. ;


这篇关于我如何通过Javascript调用php函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆