Last active
March 16, 2017 23:28
-
-
Save afr-dt/abdf7bd8eba1cb2785d98cfd73bcbb16 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
/* | |
* Method ajax for canal and medio | |
*/ | |
$('#hospital_id').change(function(){ | |
var data = ""; | |
var url = $(this).data('url'); | |
var params = 'hospital_id=' + $('#hospital_id').val(); | |
$.ajax({ | |
type : "GET", | |
url : url, | |
data : params, | |
async : true, | |
success : function(data) { | |
console.log(data.room_options) | |
var medio = $('#medio'); | |
medio.find('option') | |
.remove() | |
$.each(data.room_options, function(key, value) { | |
$('#medio') | |
.append($("<option/>") | |
.attr("value",key.room_options) | |
.text(value.name).val(value.id)); | |
$('#medio').select2(); | |
}); | |
}, | |
error : function() { | |
alert ('Ha ocurrido un error'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment