"not well-formed" warning when loading client-side JSON in Firefox via jQuery.ajax "not well-formed" warning when loading client-side JSON in Firefox via jQuery.ajax ajax ajax

"not well-formed" warning when loading client-side JSON in Firefox via jQuery.ajax


Sometimes using an HTTP server is not an option, which may mean that MIME types won't be automatically provided for some files. Adapted from Peter Hoffman's answer for jQuery .getJSON Firefox 3 Syntax Error Undefined, use this code before you make any $.getJSON() calls:

$.ajaxSetup({beforeSend: function(xhr){  if (xhr.overrideMimeType)  {    xhr.overrideMimeType("application/json");  }}});

Or, if you're using $.ajax():

$.ajax({  url: url,  beforeSend: function(xhr){    if (xhr.overrideMimeType)    {      xhr.overrideMimeType("application/json");    }  },  dataType: 'json',  data: data,  success: callback});


Local files and scripting don't mix. Way too much browser security stuff and other weirdness involved. If you want to test things, you should run your stuff through a HTTP server. Installing one locally might be a good idea.