Get the content onchange event using Jquery Ajax

View file :

———–

function get_org_address(org_name)
{
$.ajax({
type : “POSt”,
url : “<?php echo DOMAIN_URL?>registration/get_organization_address”,
data : ‘org_name=’+org_name,
success : function (res)
{
//alert(res);
//alert(res);
var address = JSON.parse(res);
//alert(address.zip_code);
$(“#address_one”).val(address.address_1);
$(“#address_two”).val(address.address_2);
$(“#city”).val(address.city);
$(“#state”).val(address.state);
$(“#main_ph_no”).val(address.phone_no);
$(“#zip_code”).val(address.zip_code);
//var zip_code = address.zip_code;
//document.getElementById(‘zip_code’).value = zip_code;
}
});
}


Controller File :

——————–

function get_organization_address()
{
$org_name = $this->input->post(‘org_name’);
$this->db->select(‘MAIN_PH_NBR,ADDR_LN_1,ADDR_LN_2,CITY,STATE,ZIP_CODE’);
$this->db->where(‘ORG_ID’,$org_name);
$this->db->from(TBL_ORGANIZATION);
$query = $this->db->get();
if($query->num_rows() > 0)
{
$data = $query->result();
$org_address = array(‘phone_no’ =>$data[0]->MAIN_PH_NBR,
‘address_1’=>$data[0]->ADDR_LN_1,
‘address_2’=>$data[0]->ADDR_LN_2,
‘city’=>$data[0]->CITY,
‘state’=>$data[0]->STATE,
‘zip_code’=>$data[0]->ZIP_CODE);
print json_encode($org_address);
}
//print_r($data);
}

Advertisements

Ajax request using POST method

function update_partial_payment(id)
{
$.ajax({
type: ‘POST’,
url: api_url+’tb_package/update_partial_payment/’,
data: {package_id:id},
success: function() {
location.reload();
}
});
}