Q:

File Uploader using ForceTK using multipart message not working in mozilla

I have been trying to upload file from Visualforce using the blog tutorial on developerforce that explains CORS feature.I am preferring REST API tied with VF since I need to built lot of other client side actions based on response like progress bar and other cool features 
https://developer.salesforce.com/blogs/developer-relations/2015/01/spring-15-preview-cors-force-com-rest-api.html
I used exact same code with forceTk imported in my VF 
<apex:page docType="html-5.0" title="File Uploader">
<h3>Select a file to upload as a new Chatter File.</h3>
 <input type="file" id="file" onchange="upload()"/>
 <p id="message"></p>
 <script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
 <script src="{!$Resource.forcetk}"></script>
 <script>
var client = new forcetk.Client();

// Get the token from Visualforce
client.setSessionToken('{!$Api.Session_ID}');

function upload() {
  var file = $("#file")[0].files[0];
  client.createBlob('ContentVersion', {
    Origin: 'H', // 'H' for Chatter File, 'C' for Content Document
    PathOnClient: file.name
  }, file.name, 'VersionData', file, function(response){
    console.log(response);
    $("#message").html("Chatter File created: <a target=\"_blank\" href=\"/" + 
      response.id + "\">Take a look!</a>");
  }, function(request, status, response){
    $("#message").html("Error: " + status);
    });
  }
</script>
</apex:page>

trying for few hours now I get below error in the javascript console only for firefox browser .Worked well in chrome 

It worked well in chrome but chrome also throws an error but still file upload succeeds while in mozilla it fails .
In chrome the error message is as below

Any help will be appreciated

A:

The comment in the data was a red herring - that's just JavaScript code, rather than JSON, so comments are perfectly ok.
I tracked the issue down to line 326 of forcetk.js:
return this.asyncAjax ? JSON.parse(request.response) : null;

Here, the blob function should return either null, if this is an asynchronous call (the usual case), or JSON.parse(request.response) for the synchronous case.
Now the problem is that, as written above, the logic is reversed! In the usual, async case, we are trying to parse an empty response, where we should be returning null.
Easy fix - I just pushed it to the repo.

