为什么当重定向页面而不是直接调用时,jQuery getJSON函数不会执行?

我有一个JSP页面,随后调用几个jQuery.getJSON()函数。 我渲染一些图表,一切都很好。 用户单击菜单项(URL)以调用此JSP页面。

getJSON函数和处理脚本在$(document).ready(function()...内执行$(document).ready(function()...

但是,当用户在登录后重定向到同一页面时,这些function将不会执行。 我想我必须遗漏一些关于Ajax或jQuery的基本信息,但经过几个小时的网络搜索后我找不到答案。

这是JSP文件:

           function changeDivHTML() { document.getElementById('chart-container-1').innerHTML = ""; }      $(document).ready(function() { $(function() { // --- $.getJSON('../../JScriptUtils.do?method=getProjectRisks', function(arr) { chartRisks = new Highcharts.Chart({ chart: { renderTo: 'chart-container-1', defaultSeriesType: 'column', borderWidth: 2 }, title: { text: 'Project Risk Profile' }, subtitle: { text: 'All Open Risks by Project' }, tooltip: { formatter: function() { return ''+ this.x +': '+ this.y +' logins'; } }, xAxis: { categories: arr.name, labels: { rotation: -45, align: 'right', style: { font: 'normal 8px Verdana, sans-serif' } }}, yAxis: { min: 0, max: 50, title: { text: 'Risks' }, tickInterval: 10 }, series: [ { data: arr.data, dataLabels: { enabled: true, formatter: function() { return this.y; } }, name: 'Risks Raised' } ] }); }); // +++ }); // function() }); // ready()   

// Display the spinner icon until ready .. changeDivHTML();

任何帮助是极大的赞赏。

好的 – 是的,因为上下文路径是硬编码的。 为了解决这个问题,我用src="<%=request.getContextPath()%>/js/jquery.js">替换了像../js/jquery.js这样的引用。

现在它有效..希望我没有浪费任何人的时间。