locked
XmlHttpRequest status 0 in FF RRS feed

  • Question

  • Hello, I am trying to use the Sync Framework with HTML5 sample, but when I send the XmlHttpRequest, in SyncFormatter.js, if I´m using Internet Explorer, the XmlHtmlRequest ststus is 200 (ok), but with Firefox the status is 0.

    Any help will be appreciated.

    The service Uri:

    downloadServiceUri: "http://157.56.8.203:80/DefaultScopeSyncService.svc/defaultscope/DownloadChanges?id=",
    uploadServiceUri: http://157.56.8.203:80/DefaultScopeSyncService.svc/defaultscope/UploadChanges?id=

    Code:

    // SyncFormatter is the class to serialize/deserialize between entity and its
    // wire format as defined in the sync protocol
    function SyncFormatter() {
        // Flag to indicate whether there is more change
        this.moreChangesAvailable = false;
        // Server blob
        this.serverBlob = "";
        // List of updated entities
        this.results = new Array();
        // Deserialize payload to entity
        this.parse = function (str) {
            try {
                var data = JSON.parse(str);
                this.moreChangesAvailable = data.d.__sync.moreChangesAvailable;
                this.serverBlob = data.d.__sync.serverBlob;
                this.results = data.d.results;
                return true;
            } catch (err) { }
            return false;
        };
        // Serialize entity to payload object
        this.dataObject = function () {
            var data = new Object();
            data.d = new Object();
            data.d.__sync = new Object();
            data.d.__sync.moreChangesAvailable = this.moreChangesAvailable;
            data.d.__sync.serverBlob = this.serverBlob;
            data.d.results = this.results;
            return data;
        };
        // Serialize payload object to its wire format
        this.toString = function () {
            return JSON.stringify(this.dataObject());
        };
        // Send request to sync service
        this.sendRequest = function (serviceUri, successCallback, errorCallback, dir) {
     
            TraceObj("[" + dir + " Request]:", serviceUri, this.dataObject());
            // Construct HTTP POST request
            var xmlHttp = new XMLHttpRequest();
            xmlHttp.open("POST", serviceUri);
            xmlHttp.setRequestHeader("Accept""application/json");
            xmlHttp.setRequestHeader("Content-Type""application/json");
            // Handle success & error response from server and then callback
            xmlHttp.onreadystatechange = function () {
                if (xmlHttp.readyState == 4) {
                    if (xmlHttp.status == 200) {
                        var res = new SyncFormatter();
                        if (res.parse(xmlHttp.responseText)) {
                            TraceObj("[" + dir + " Response]:", serviceUri, res.dataObject());
                            alert("[" + dir + " Response]:", serviceUri, res.dataObject());
                            successCallback(res);
                            return;
                        }
                    }
                    TraceMsg("[" + dir + " Response Error]: ", xmlHttp.status + " Response: " + xmlHttp.responseText);
                    errorCallback(xmlHttp.responseText);
                }
            };
            xmlHttp.send(this.toString());
        };
    }

     

    James.

    Thursday, November 24, 2011 1:31 PM

All replies

  • what version of FF are you running? are you running everything locally?

    if i remember it right, status=0 is normally related to cross-domain issues.

    Thursday, November 24, 2011 2:19 PM
  • I´m using FF 8.0, and also tried in Chrome, but I recived the some status.

    The service is running in the cloud and it´s live.

    Thanks for your help,

    James

    Thursday, November 24, 2011 2:43 PM
  • then its a cross domain issue. you can lots of discussions around it.
    Thursday, November 24, 2011 3:11 PM
  • Hello, I have been searching the solution to my problem, but I couldn´t find the answer.
    I catched the error log in the service:
     
    And here are the Requests frames:
     
    IE:
    POST http://157.56.8.203/DefaultScopeSyncService.svc/defaultscope/DownloadChanges?id=7AE7C771-0A98-4A5D-A046-430DDB0A7917 HTTP/1.1
    Content-Type: application/json
    Accept-Language: en-us
    Referer: http://localhost:49427/ListSample.htm
    Accept: application/json
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
    Host: 157.56.8.203
    Content-Length: 1092
    Connection: Keep-Alive
    Pragma: no-cache
    
    {"d":{"__sync":{"moreChangesAvailable":false,"serverBlob":"AAEAAAD/////AQAAAAAAAAAMAgAAAGVNaWNyb3NvZnQuU3luY2hyb25pemF0aW9uLlNlcnZpY2VzLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49ODk4NDVkY2Q4MDgwY2M5MQUBAAAAK01pY3Jvc29mdC5TeW5jaHJvbml6YXRpb24uU2VydmljZXMuU3luY0Jsb2IFAAAAIDxDbGllbnRLbm93bGVkZ2U+a19fQmFja2luZ0ZpZWxkIDxDbGllbnRTY29wZU5hbWU+a19fQmFja2luZ0ZpZWxkHDxJc0xhc3RCYXRjaD5rX19CYWNraW5nRmllbGQaPEJhdGNoQ29kZT5rX19CYWNraW5nRmllbGQaPE5leHRCYXRjaD5rX19CYWNraW5nRmllbGQHAQADAwIBbVN5c3RlbS5OdWxsYWJsZWAxW1tTeXN0ZW0uR3VpZCwgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV1tU3lzdGVtLk51bGxhYmxlYDFbW1N5c3RlbS5HdWlkLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldXQIAAAAJAwAAAAYEAAAAJDJjZDY3ZThiLTI5YWEtNDMzOS1hODk1LTg0MzRhOTJhMDMwYQEKCg8DAAAAkAAAAAIAAAAFAAAAAAAAAAEAAAAAAAAABQAAEAAAAAIs1n6LKapDOaiVhDSpKgMKihAsJmezSvK+fDi8iU2mQgAAABgAABABKAIAAAEAAAAVAAAAAgAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAEsAAAAXAAAAAQAAABYAAAABAAMAAAAAAQAAAAAAAAAZAQAAAAAL"},"results":[]}}
    

    FF:
    OPTIONS http://157.56.8.203/DefaultScopeSyncService.svc/defaultscope/DownloadChanges?id=7AE7C771-0A98-4A5D-A046-430DDB0A7917 HTTP/1.1
    Host: 157.56.8.203
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip, deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Connection: keep-alive
    Origin: http://localhost:49427
    Access-Control-Request-Method: POST
    Access-Control-Request-Headers: content-type
    Pragma: no-cache
    Cache-Control: no-cache

    Can anyone help me?
    Thanks,
    James.-
     

    Monday, November 28, 2011 11:08 AM