Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery填充选择框页面加载时没有值(计时?)_Javascript_Jquery_Ajax_Laravel 5 - Fatal编程技术网

Javascript jQuery填充选择框页面加载时没有值(计时?)

Javascript jQuery填充选择框页面加载时没有值(计时?),javascript,jquery,ajax,laravel-5,Javascript,Jquery,Ajax,Laravel 5,对jquery有点问题,但尚未找到解决方案: 当页面加载到那里时,选择框中会充满来自MySQL的数据。但该值是“未定义的” 在ajax调用中使用console.log(data)检查数据。您是否将$('#hersteller')放在文档就绪中的('change')事件上?“不起作用”是一个几乎毫无意义的问题陈述,尤其是当代码中涉及大量操作时。花些时间阅读并编辑问题,并给出详细的问题解释,包括什么可行或不可行、错误等 $(document).ready(function(){ $.get("{{

对jquery有点问题,但尚未找到解决方案:

当页面加载到那里时,选择框中会充满来自MySQL的数据。但该值是“未定义的”


在ajax调用中使用
console.log(data)
检查数据。您是否将
$('#hersteller')放在文档就绪中的('change')
事件上?“不起作用”是一个几乎毫无意义的问题陈述,尤其是当代码中涉及大量操作时。花些时间阅读并编辑问题,并给出详细的问题解释,包括什么可行或不可行、错误等
$(document).ready(function(){
$.get("{{ URL::to('getHersteller')}}", function(data){
    $.each(data,function(i,value){
        var option =$("<option>",
                    {text : value.hersteller}
                                )
        $('#hersteller1').append(option);
    })
})
var select = $("#hersteller1 option:selected").val();
console.log(select);
$('#hersteller1').on('change', function(e){
$('#modell1').empty()
var herstellerAuswahl=e.target.value; 
$.ajax({
    type: 'post',
    url:'{{route('readHersteller')}}',
    dataType: "json",
    data:{'title':herstellerAuswahl},
    success:function(data){ 
        $.each(data,function(j,value){
            var option =$("<option>",
                        {text : value.modell})
            $('#modell1').append(option);
        })
    }
})