$("document").ready( function(){ $(".international").hide(); $(".us").hide(); //$("#buyNow").show(); $.ajax({ type:"GET", url:"http://www.esri.com/special/agol/agol_trial_pricing.xml", dataType:"text", success:function(xmlString){ internationalOptions = xmlToJson(xmlString, true); $.ajax({ type: "GET", url: "/shared/services/index.cfm?event=location.getCountryByIp", dataType: "json", // Remove the comments below to test for outside of U.S. //data: "address=4.18.32.72", /* * 4.21.164.192 (US) * 4.17.143.0 (Canada) * 4.18.32.72 (Mexico) * 194.225.70.1 (Iran) */ success: function(msg){ if (msg.status == 0){ var columnNameRow = internationalOptions.Workbook.Worksheet[0].Table.Row[1], indexOfCC = columnNameRow.Cell.indexOfAlt("Two-letter Country Code",function(item){return item.Data;}), indexOfTrial = columnNameRow.Cell.indexOfAlt("Free Trial Subscription Form Access",function(item){return item.Data;}), row = internationalOptions.Workbook.Worksheet[0].Table.Row.filter(function(row){return row.Cell[indexOfCC].Data==msg.data.country;})[0]; if (row) { var showTrial = row.Cell[indexOfTrial].Data=="Opted In"; // No errors if (msg.data.country == "US" || showTrial){ // Allowed $(".us").show(); }else{ // Not Allowed $(".international").show(); } //} else if (msg.data.country == "US" ) { } else if (msg.data.country != "UNKNOWN" ) { $(".us").show(); } else { $(".international").show(); } }else{ // Error $(".international").show(); } } }); } }); });