Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.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
Php $undefined即使jquery已加载_Php_Jquery_Laravel - Fatal编程技术网

Php $undefined即使jquery已加载

Php $undefined即使jquery已加载,php,jquery,laravel,Php,Jquery,Laravel,好的,这是我的问题 我使用下面的页面获取用户时区 <html> <head> <script src="/js/jquery-2.1.4.js"></script> <script src="/js/jstz-1.0.4.min.js"></script> </head> <body> <form id="tz-form"

好的,这是我的问题 我使用下面的页面获取用户时区

<html>
    <head>
        <script src="/js/jquery-2.1.4.js"></script>
        <script src="/js/jstz-1.0.4.min.js"></script>
    </head>
    <body>
        <form id="tz-form" action="{{ URL::to('/') }}" method="post">
            <input id="tz" type="hidden" name="timezone" value="">
        </form>
        <script>
            $(document).ready(function(){
                var timezone = jstz.determine();
                $('#tz').val(timezone.name());
                $('#tz-form').submit();
            });
        </script>
    </body>
</html>

$(文档).ready(函数(){
var timezone=jstz.determine();
$('#tz').val(timezone.name());
$(“#tz表单”).submit();
});
运行应用程序时,firebug会显示以下错误


  • SyntaxError:预期表达式,得到“好的,我找到了解决方案,这是从

    jQuery.noConflict(true)

    如前所述,这会自动添加到页面中

    因此,我将“更改脚本”添加到该脚本中,它成功了。:)

    
    var jq=jQuery.noConflict();
    jq(文档).ready(函数(){
    var timezone=jstz.determine();
    jq('#tz').val(timezone.name());
    jq(“#tz表单”).submit();
    });
    
    指向JS库的路径似乎是错误的。Laravel显示了一个导致JavaScript错误的404文档。JS库加载,firebug“Net”面板200OK您在JS文件中有html标记吗?第一个错误看起来是这样的。如果访问
    /
    ,这段代码是否会卡在永久的重新加载页面循环中?不,它会在html文件中显示第一个标记。
        <script>
            var jq = jQuery.noConflict();
            jq(document).ready(function(){
                var timezone = jstz.determine();
                jq('#tz').val(timezone.name());
                jq('#tz-form').submit();
            });
        </script>