2012-05-02 4 views
0

내가 지금 같은 아약스 호출 중대한 작업 위도와 경도 조회가 있습니다지오 코더 구글지도 위도와 경도 조회

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<script type="text/javascript"> 

var geocoder = new google.maps.Geocoder(); 
var address = "<?php echo addslashes($_POST['street'].' '.$_POST['house_number'].', '.$_POST['postal_code'].', '.$_POST['city'].', '.$_POST['country']); ?>"; 

geocoder.geocode({ 'address': address}, function(results, status) { 

    if (status == google.maps.GeocoderStatus.OK) { 

     var latitude = results[0].geometry.location.lat(); 
     var longitude = results[0].geometry.location.lng(); 
     var request_key = '<?php echo $ajax_request_key; ?>'; 
     var url = '<?php echo $settings['base_url'].'/site/templates/ajax/add_vacancy_latitude_and_longitude.php?vacancy_id='.$_POST['vacancy_id']; ?>'; 

     //add longitude and latitude to database 
     $.post(url, { this_latitude:latitude, this_longitude:longitude, this_request_key:request_key }, function(data) { }); 

    } 

}); 
</script> 

그러나 아약스 호출이 경우에만 작동합니다. 내가 두 번째 페이지로드 (예 : 사용자가 자신의 우편 번호를 입력하는 검색 양식을 가지고 있지 않고 즉시 공석에 대한 내 mysql 데이터베이스를 쿼리 할 수있는 HTTP 요청을 할 수있는 방법이 있나요? 즉시 우편물의 경도와 위도를 데이터베이스와 비교하십시오.

내가 지금 생각할 수있는 방법은 jquery로 제출을 방지하고 ajax 호출을 작성하여 경매와 위도를 데이터베이스, 다음 양식을 작성하고 저장 경도와 위도로 데이터베이스를 조회는. 어떻게 든 내가 더 효율적인 방법이있을 것 같아요.

감사합니다! 스콧

+2

당신은 PHP에서 사용 컬을 시도 할 수 있습니다, 당신은 페이지로드 http://php.net/manual/en/book.curl.php 전에 – YamahaSY

답변