Last active
June 15, 2019 21:04
-
-
Save wvpv/8e38dd31ae3be0ae64d05fa5fb1d8ecf 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 time = Platform.Function.Now(); | |
var today = new Date(time); | |
var tomorrow = today.setDate(today.getDate() + 1); | |
Platform.Response.SetCookie("auth", Platform.Function.GUID(), tomorrow, true); | |
</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/szmvqgfm5sp?state=" + state, | |
dataType: "json", | |
contentType: "application/json", | |
cache: !1, | |
timeout: 1e4, | |
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