function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Surendra nuneSurendra nune 

IE11 browser Issue: Facing issue with Forcetk.js(Rest toolkit), Parameter is incorrect

I am using IE11 browser. I am using Forcetk.js to for file upload into content version. The script is working fine in Mozilla and Chrome.
But in IE11, I get the below error in Forcetk.js file. Please help if any one faced similar issue.User-added image
Sunil MadanaSunil Madana
hi Surendra,
i used the below code and it works fine on IE 9, 10 & 11.
<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();    
    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>
Please share your code, if it is fine.
I used the above code from: https://github.com/developerforce/Force.com-JavaScript-REST-Toolkit (https://github.com/developerforce/Force.com-JavaScript-REST-Toolkit" target="_blank)

Thanks, Sunil
J L 5J L 5
Hi,

I ran into this same problem with custom visualforce page and reason for that was that the page included apex:actionFunction component which: "actionFunctions send the page ViewState in the AJAX XmlHttpRequest and return a blob of XML (apparently using the Sarissa open source library) in the response, which has a slightly slower performance than what you'd get using JQuery's native AJAX utility methods." (quote from http://www.embracingthecloud.com/categoryview,category,visualforce.aspx). Seems that because of actionFunction (and possibly other VF components also) standard window.XMLHttpRequest is replaced in IE with Sarissa.js which doesn't work with ForceTK. Solution was to modify forcetk to get original xmlhttprequest if it was over-written by sarissa: 
forcetk.Client.prototype.blob = function (path, fields, filename, payloadField, payload, callback, error, retry) {
        'use strict';
        var that = this,
            url = (this.visualforce ? '' : this.instanceUrl) + '/services/data' + path,
            boundary = randomString(),
            blob = new Blob([
                "--boundary_" + boundary + '\n'
                    + "Content-Disposition: form-data; name=\"entity_content\";" + "\n"
                    + "Content-Type: application/json" + "\n\n"
                    + JSON.stringify(fields)
                    + "\n\n"
                    + "--boundary_" + boundary + "\n"
                    + "Content-Type: application/octet-stream" + "\n"
                    + "Content-Disposition: form-data; name=\"" + payloadField
                    + "\"; filename=\"" + filename + "\"\n\n",
                payload,
                "\n\n"
                    + "--boundary_" + boundary + "--"
            ], {type : 'multipart/form-data; boundary=\"boundary_' + boundary + '\"'});
        var request = null;
        if(Sarissa.originalXMLHttpRequest) {
            request = new Sarissa.originalXMLHttpRequest();
        } else if (window.XMLHttpRequest) {
            request = new XMLHttpRequest();
        }
        request.open("POST", (this.proxyUrl !== null && !this.visualforce) ? this.proxyUrl : url, this.asyncAjax);
        ...
Sarabjeet Pal 24Sarabjeet Pal 24
Hi, Did anyone solve this problem, I get the same issue as Surendra??