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() {
            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

  • Where is your data.json file? Have you tries jQyery.ajax instead of $.ajax? Commented Apr 11, 2012 at 7:28
  • Thank you for your response. Yes, I trid. The data.json file is in the "_layouts/1033/STYLES/MyWebPart/" folder where jQuery and HighCharts is there too.
    – Vahid
    Commented Apr 11, 2012 at 8:35
  • Then specifying '/_layouts/1033/STYLES/MyWebPart/data.json' as url should work. What is fiddler giving you for that? Commented Apr 11, 2012 at 8:42
  • Server Error in '/' Application. (Runtime Error) and it says: set <customErrors mode="RemoteOnly"/> in web.config. But I don't have web.config file in WebPart Solution.
    – Vahid
    Commented Apr 11, 2012 at 9:17
  • Change the web.config in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS Commented Apr 11, 2012 at 9:31

1 Answer 1


Due to this line:

<add name="JSONHandlerFactory" path="*.json" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" preCondition="integratedMode" />

in the <system.webServer><handlers> section in the standard SharePoint 2010 web.config. SharePoint (well in fact ASP.NET) assumes that any file with the extension .json should be json enabled web services.

So if your data.json is just data then you have to give it another extension.

  • Thank you Per Very Much. It works now with another extension. So, how can I call a .json file? How can I use this web service? Any references?
    – Vahid
    Commented Apr 11, 2012 at 10:11
  • There is one article here Commented Apr 11, 2012 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.