Jquery getJson

//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);
}

Jquery getJson,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。