Last active
June 15, 2019 21:04
-
-
Save wvpv/6c920ecb2e41bcc3c25c3b2f08f431f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script runat="server"> | |
Platform.Load("core", "1"); | |
var thisIP = Platform.Request.ClientIP; | |
</script> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>Cities</title> | |
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> | |
</head> | |
<body> | |
<h4>Cities</h4> | |
<label>State:</label> <input type="text" name="state" id="state" size="2"> | |
<p><button type="button" class="btn">Load Cities</button></p> | |
<p class="cities"></p> | |
<script type="text/javascript"> | |
$('.btn').click(function() { | |
$('.cities').text('Loading...'); | |
var state = $('#state').val(); | |
$.ajax({ | |
type:"GET", | |
url:"https://pub.s7.exacttarget.com/f2yvotitjqj?state=" + state, | |
dataType: "json", | |
contentType: "application/json", | |
cache: !1, | |
timeout: 1e4, | |
beforeSend: function(request) { | |
request.setRequestHeader("auth", "<ctrl:var name=thisIP />"); | |
}, | |
success: function(data) { | |
console.log(data) | |
var $el0 = $('.cities'); | |
$el0.empty(); | |
$el0.append($("<select></select>").attr("class","cityList")); | |
var $el = $('.cityList'); | |
$el.append($("<option></option>").attr("value", '').text('Select City')); | |
$.each(data.results, function(value, key) { | |
$el.append($("<option></option>").attr("value", key.City).text(key.City + ", " + key.State)); | |
}); | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment