1

Here is my code:

var jsonURL = "http://www.sodexo.fi/ruokalistat/output/daily_json/440/2013/10/25/fi";

    var request = $.ajax({
        url: jsonURL,
        dataType: "json",
        type: "GET"
    });

    request.done(function( msg ) {
        alert(msg);
    });

    request.fail(function( jqXHR, textStatus ) {
      alert( "Request failed: " + textStatus );
    });

What am i doing wrong? Im getting only parsererror with this code. Thank you guys for helping.

samiljin
  • 93
  • 8

1 Answers1

1

Looking at the raw HTTP response using Fiddler I see:

3f6
{ /* what likes like JSON here */ }
0

i.e. looks like your server is putting random characters around the JSON block which may be what's upsetting the jQuery parser.

edit

If you can't get the server response to change, you could change the dataType to 'text' and parse it yourself if the format is consistent. Looking at it, I suspect the first line is the length of the message and the last line a terminator. Once you've stripped those chars just parse the JSON using JSON.parse

Tim Croydon
  • 1,866
  • 1
  • 19
  • 30