Skip to content

Instantly share code, notes, and snippets.

@taleeb35
Created September 16, 2014 06:06
Show Gist options
  • Save taleeb35/5ae31fd4bce29d772667 to your computer and use it in GitHub Desktop.
Save taleeb35/5ae31fd4bce29d772667 to your computer and use it in GitHub Desktop.
$(function() {
$('#countries').change(function() {
var selectedValue = $(this).val();
var targeturl = $(this).attr('rel') + '?id=' + selectedValue;
$.ajax({
type: 'get',
url: targeturl,
beforeSend: function(xhr) {
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
},
success: function(response) {
if (response.content) {
$('#states').html(response.content);
}
},
error: function(e) {
alert("An error occurred: " + e.responseText.message);
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment