从动态相关选择框jQuery获取值选项
我试图从AJAX jQuery生成的选择框中选择该选项。这是我的密码:从动态相关选择框jQuery获取值选项,jquery,jquery-ajaxq,Jquery,Jquery Ajaxq,我试图从AJAX jQuery生成的选择框中选择该选项。这是我的密码: <script> $(document).ready(function(){ var current_select; $('#pedido_domicilio,#pedido_sucursales').on('change', function(){ var countryID = $('#pedido_domicilio').val();
<script>
$(document).ready(function(){
var current_select;
$('#pedido_domicilio,#pedido_sucursales').on('change', function(){
var countryID = $('#pedido_domicilio').val();
var countryIDsel = $('#pedido_domicilio :selected').val();
current_select = $('#pedido_sucursales option:selected').val();
if(countryID){
$.ajax({
type:'POST',
url:'URL',
data:'pedido_domicilio='+countryID,
dataType: 'json',
cache: false,
success:function(html){
$('#pedido_sucursales').html(html.opciones);
}
});
$.ajax({
type:'POST',
url:'URL',
data:'pedido_domicilio='+countryIDsel,
cache: false,
success:function(html){
$('#wizard_pedido_domicilio').html(html);
}
});
$.ajax({
type:'POST',
url:'URL',
data:'pedido_sucursal='+current_select,
cache: false,
success:function(html){
$('#wizard_pedido_sucursal').html(html);
}
});
}
}).trigger('change');
});
</script>
我可以获取当前值,但不能实时获取。当我更改pedidos\u domicilio时,我不会收到pedidos\u sucursales上加载的值,但如果我再次更改pedidos\u domicilio,我会获取之前需要显示的值。这是否回答了您的问题?