//js
function get_addressinfo(x){
var zipcode = $("#"+x+"_zipcode").val();
$.getJSON("ebanx/zipcode", {zipcode: zipcode}, function(msg){
if(msg[‘status‘] == ‘SUCCESS‘){
var addressinfo = msg[‘zipcode‘];
$("#"+x+"_state").val(addressinfo[‘state‘]);
$("#"+x+"_city").val(addressinfo[‘city‘]);
$("#"+x+"_address").val(addressinfo[‘address‘]);
}else{
alert(‘invaled zipcode, please enter again‘);
}
});
}
//application/control/ebanx/zipcode
public function zipcode(){
$url = $this->url.‘zipcode‘;
$zipcode = $_GET[‘zipcode‘];
$res_merch = $this->pay_order->get_method_info_by_class_name(‘ebanx‘);
$res = $this->pay_order->get_merchant_data_by_pay_type($res_merch[0][‘pay_type_id‘], $res_merch[0][‘method_id‘]);
$params = array(
‘integration_key‘ => $res[0]->merchant_key,
‘zipcode‘ => $zipcode);
log_message(‘gash‘, ‘zipcode parameters: ‘.json_encode($params));
$query_res = $this->_makeRequest($url, $params, ‘get‘);
$result_array = json_decode($query_res[‘msg‘], TRUE);
log_message(‘gash‘, ‘zipcode result: ‘.json_encode($result_array));
echo json_encode($result_array);
}
原文地址:http://www.cnblogs.com/barfoo/p/3921754.html