Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/409.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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
$.filedownload在javascript中给出“$未定义”_Javascript_Jquery - Fatal编程技术网

$.filedownload在javascript中给出“$未定义”

$.filedownload在javascript中给出“$未定义”,javascript,jquery,Javascript,Jquery,我对jquery和js非常陌生,但在myphp.php文件中有以下代码: <?php echo "<div><tr><a href='javascript:getspreadsheets();'>Cape Culture (10 years)</a></tr><br />"; echo "<tr><a href='javascript:getspreadsheets();'>Winsters (

我对jquery和js非常陌生,但在myphp.php文件中有以下代码:

<?php
echo "<div><tr><a href='javascript:getspreadsheets();'>Cape Culture (10 years)</a></tr><br />";
echo "<tr><a href='javascript:getspreadsheets();'>Winsters (5 Years)</a></tr><br />";
echo "<tr><a href='javascript:getspreadsheets();'>Kayo (1 year)</a></tr><br />";
echo "<tr><a href='javascript:getspreadsheets(1498);'>Col Timbers</a></tr></div>";
?>

  <script type="text/javascript">
function getspreadsheets(val)
{
    alert(val);
    var self = this,

        activityguid = self.activityguid,
        accountguid  = self.accountguid

        $.fileDownload(
            'data/export.items_to_csv.php',
            {
                httpMethod: 'POST',
                data: {
                    activityguid : activityguid,
                    accountguid  : accountguid,
                    classid      : val
                }
            });
        alert(val);
    //}
}
 </script>
当我运行它时,我得到了第一个警报,但随后得到一个错误,说明$is undefined? 有人能帮忙吗?
谢谢

听起来要么没有包含jQuery,要么在脚本之后包含它。确保jQuery脚本标记位于应用程序脚本之前。

确保您的include for jQuery位于此脚本部分之前,并且您实际包含了jQuery。

添加此代码

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">

是否链接到jquery脚本?是否包含jquery?是否包含jquery脚本?这里有一个来自Google CDN的代码:让我添加我的其他代码因为脚本是同步加载的,关于jQuery没有及时加载的声明在提供的上下文中似乎是无效的。实际上,最好在文档结束之前将所有脚本都放在文档的末尾。此外,jQuery将始终及时加载,因为脚本是同步加载的。出现问题的唯一方法是,如果由于标记中的async属性,脚本以异步方式加载。没有异步,没有问题。事实上是这样的。我这方面有点傻哈哈。编辑了原始答案