我是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>
当我运行它时,我得到第一个警报,但后来得到一个错误,说明$未定义? 有人可以帮忙吗? 感谢
答案 0 :(得分:1)
确保您的jQuery包含在此脚本部分之前,并且您实际上包含了jQuery。
答案 1 :(得分:0)
听起来你要么不包括jQuery,要么在你的脚本之后包含它。在应用程序脚本之前确保jQuery脚本标记是。
答案 2 :(得分:0)
添加此代码
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">