Sarath created CB-10189:
---------------------------

             Summary: ajax call fails when using signed apk
                 Key: CB-10189
                 URL: https://issues.apache.org/jira/browse/CB-10189
             Project: Apache Cordova
          Issue Type: Bug
         Environment: cordova
            Reporter: Sarath
            Priority: Critical


The ajax returned error when using signed apk but it is working correctly with 
unsigned build and with the simulator.

 var queryUrlBase = 
"https://api.votermapping.com/api/v1/customer/application/datasource/records/count/";;
    var apiKey = "cfad5f652c327cce14884700f549a980";
    var apiUser = "audiencepartners";

    var stateAbbr = this.state.toLowerCase();
    var genderTerm = null;
    var partiesTerm = null;
    var ageTerm = null;
    var cngDistrictTerm = null;
    this.hasQueryError = false;
    if(this.gender != null) {
        if(this.gender == "ALL") {
            genderTerm = "&filter.Voters_Gender=M,F";
        } else {
            genderTerm = "&filter.Voters_Gender=" + this.gender;
        }
    }
    if(this.parties.length > 0) {
        partiesTerm = "&filter.Parties_Description=";
        partiesTerm += this.parties.join(",");
    }
    if(this.age != null) {
        ageTerm = "&filter.Voters_AgeRange=" + this.age;
    }
    if(this.cngDistrict != null) {
        cngDistrictTerm = "&filter.2011_NEW_Congressional_District=" + 
this.cngDistrict;
    }
    var queryUrl = queryUrlBase + "lnl_" + stateAbbr + "_"+apiUser+"/lnl_" + 
stateAbbr + "_2013";
    queryUrl = queryUrl + "?id=" + apiUser + "&apikey=" + apiKey;
    if(genderTerm != null) {
        queryUrl += genderTerm;
    }
    if(partiesTerm != null) {
        queryUrl += partiesTerm;
    }
    if(ageTerm != null) {
        queryUrl += ageTerm;
    }
    if(cngDistrictTerm != null) {
        queryUrl += cngDistrictTerm;
    }
    console.log("RUNNING QUERY " + queryUrl);
    var self = this;
    if(!this.runInBackground) {
        showLoader();
    }
    
    $.ajax({ 
        cache: false,
        url: queryUrl,
        timeout: 30000,
        success: function (data) {
            if(data.result == "ok") {
                if(!self.runInBackground) {
                    CampaignGrid.voterCount = data.count;
                    if(data.count > 0) {
                        var adjustedCount =  Math.round(parseInt(data.count) * 
self.primaryPropensity * self.generalPropensity);

                        
$("#spnVoterCountText").text(formatCount(adjustedCount));
                        $("#btnGo").removeClass("disabled");
                        $("#divVoterCount").removeClass("disabled");
                        $("#divVoterCount").addClass("hasCount");

                    } else {
                        $("#btnGo").addClass("disabled");
                    }    
                }
                
            } else {
                self.hasQueryError = true;
            }
        },
        error: function (xhr, ajaxOptions, thrownError) {
                         
           self.hasQueryError = true;
        }, 
        complete: function(xhr, status) {
            hideLoader();
            if(!self.runInBackground) {
                if(self.hasQueryError) {
                    flashMessage("Our servers are currently busy, please try 
again in a few minutes or call 484-928-1010.", 3);
                    $("#btnGo").addClass("disabled");
                    $("#spnVoterCountText").text("Error getting voters");
                    $("#divVoterCount").addClass("disabled");
                }

                $("#btnRefresh").show();
                $("#btnReset").show();
            }
            
        }
    });



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to