I want to use HighCharts in Sharepoint Web Parts. So, I put necessary JS files in 14 hive folder and everything works fine. This is my ScriptLink Tag:
<SharePoint:ScriptLink ID="ScriptLink1" Name="<% $SPUrl:~SiteCollection/STYLES/MyWebPart/Highcharts/js/highcharts.js%>" runat="server" />
But when I want to use AJAX, there is a problem:
I don't know how can I address the AJAX URL:
function requestData() {
$.ajax({
url: ' ?? ',
success: function(point) {
var series = chart.series[0],
shift = series.data.length > 20;
chart.series[0].addPoint(point, true, shift);
setTimeout(requestData, 1000);
},
cache: false
});
}
I have tested this solution without a chance:
url: '< % = ResolveUrl("$SPUrl:~SiteCollection/STYLES/MyWebPart/data.json") % >'
Even if I use full URL I got Runtime Error with FireBug (Net Tab): (In this situation if I use incorrect URLs I got 404 Not Found Error)
url: 'http://sharepoint/_layouts/1033/STYLES/MyWebPart/data.json'
At last if I use HighChart URL with "crossDomain: true" nothing happens:
url: 'http://www.highcharts.com/studies/live-server-data.php'
It seems Web Parts have some problems with AJAX.
Any help would be greatly appreciated
jQyery.ajaxinstead of$.ajax? – Per Jakobsen Apr 11 '12 at 7:28'/_layouts/1033/STYLES/MyWebPart/data.json'as url should work. What is fiddler giving you for that? – Per Jakobsen Apr 11 '12 at 8:42C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS– Per Jakobsen Apr 11 '12 at 9:31