function ajaxCall() { this.send = function(data, url, method, success, type) { type = type||'json'; var successRes = function(data) { success(data); } var errorRes = function(e) { console.log(e); $('#loader').modal('hide'); } $.ajax({ url: url, type: method, data: data, success: successRes, error: errorRes, dataType: type, timeout: 60000 }); } } function locationInfo() { var rootUrl = "https://ecommerce.asim.aits.work/location/api.php"; var call = new ajaxCall(); this.getCities = function(id) { $(".cities option:gt(0)").remove(); var url = rootUrl+'?type=getCities&stateId=' + id; var method = "post"; var data = {}; $('.cities').find("option:eq(0)").html("Please wait.."); call.send(data, url, method, function(data) { $('.cities').find("option:eq(0)").html("Select City"); if(data.tp == 1){ $.each(data['result'], function(key, val) { var option = $('