백엔드 (PHP)에서 모든 "처리"를 수행하고 Ajax 기능을 사용하여 관련 데이터를 전달하기를 원할 것입니다.
이상 여기 좋은 예있다 :
이
http://downloads.postcodeanywhere.co.uk/dev/pcaphpsamples.zip
http://downloads.postcodeanywhere.co.uk/dev/pcaphpsamples.zip
http://downloads.postcodeanywhere.co.uk/dev/phpSOAP.zip
당신은 또한 당신이 시작하는 데 다음과 같은 코드를 사용할 수 있습니다 :
https://www.postcodeanywhere.co.uk/address-validation/guide/default.aspx?reg=1
은 사이트에서 PHP 예제
있습니다
class PostcodeAnywhere_Interactive_FindByPostcode_v1_00
{
//Credit: Thanks to Stuart Sillitoe (http://stu.so/me) for the original PHP that these samples are based on.
private $Key; //The key to use to authenticate to the service.
private $Postcode; //The postcode to search with find.
private $UserName; //The username associated with the Royal Mail license (not required for click licenses).
private $Data; //Holds the results of the query
function PostcodeAnywhere_Interactive_FindByPostcode_v1_00($Key, $Postcode, $UserName)
{
$this->Key = $Key;
$this->Postcode = $Postcode;
$this->UserName = $UserName;
}
function MakeRequest()
{
$url = "http://services.postcodeanywhere.co.uk/PostcodeAnywhere/Interactive/FindByPostcode/v1.00/xmla.ws?";
$url .= "&Key=" . urlencode($this->Key);
$url .= "&Postcode=" . urlencode($this->Postcode);
$url .= "&UserName=" . urlencode($this->UserName);
//Make the request to Postcode Anywhere and parse the XML returned
$file = simplexml_load_file($url);
//Check for an error, if there is one then throw an exception
if ($file->Columns->Column->attributes()->Name == "Error")
{
throw new Exception("[ID] " . $file->Rows->Row->attributes()->Error . " [DESCRIPTION] " . $file->Rows->Row->attributes()->Description . " [CAUSE] " . $file->Rows->Row->attributes()->Cause . " [RESOLUTION] " . $file->Rows->Row->attributes()->Resolution);
}
//Copy the data
if (!empty($file->Rows))
{
foreach ($file->Rows->Row as $item)
{
$this->Data[] = array('Id'=>$item->attributes()->Id,'StreetAddress'=>$item->attributes()->StreetAddress,'Place'=>$item->attributes()->Place);
}
}
}
function HasData()
{
if (!empty($this->Data))
{
return $this->Data;
}
return false;
}
}
//Example usage
//-------------
//$pa = new PostcodeAnywhere_Interactive_FindByPostcode_v1_00 ("AA11-AA11-AA11-AA11","WR2 6NJ","David");
//$pa->MakeRequest();
//if ($pa->HasData())
//{
// $data = $pa->HasData();
// foreach ($data as $item)
// {
// echo $item["Id"] . "<br/>";
// echo $item["StreetAddress"] . "<br/>";
// echo $item["Place"] . "<br/>";
// }
//}
http://www.postcodeanywhere.co.uk/support/webservices/PostcodeAnywhere/Interactive/FindByPostcode/v1/default.aspx
필요한 경우 ajax를 사용하여 전화 걸기 :
jQuery.ajax({
url: "yourScript.php",
type: 'POST',
data: {action: 'get_postcode', id: ui.item.id },
success: function(data) {
try {
var response = jQuery.parseJSON(data);
jQuery('#pickPostcode').val(response.postcode);
} catch(err) {}
}
});
안녕하세요 저는이 모든 것을 지쳤습니다.하지만 모두 포스트 코드 조회가 양식 내에 있고 양식 내에 양식이 없어야하므로 실제로 할 수없는 게시 양식 요청을 수행하는 것처럼 보입니다. 나는 아약스와 같은 종류의 해결책을 원했지만 어떻게 할 것인가? – David
@David : 이것은 AJAX 솔루션입니다. 양식을 사용하지 않으려면 양식을 사용할 필요가 없습니다. – halfer
Opps 미안하지만, jquery 비트를 보지 못했 덕분에 그것을 시도 줄 것이다! – David