I don't know if anyone else has seen this.  But if anyone has and
knows a fix for it it would be great.

I am using the jquery ajax library to do a timed update (once per
minute).  I am using POST against and asmx web service.
Intermittently jquery will return an error with the requested data as
the return text and an HTTP state of 200.  Below is the code for the
ajax call.

Thanks in advance for any responses.

Below, ajax call will hit the error callback, xhr parameter will have
an http state of 200 and xhr.ResponseText.d will be the requested
data.

var WebClient = {
        ServiceURI: "/WebService.asmx",
        Timeout: 10000
}

WebClient.initialize = function() {
        $.ajaxSetup({
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                timeout: WebClient.Timeout
        });
}

WebClient.ajaxCall = function(uri, type, data, callbackSuccess,
callbackError, callId) {
        $.ajax({
                url: uri,
                type: type,
                data: data,
                cache: false,
                success: function(msg) {
                        if (callbackSuccess) {
                                if (callId) {
                                        callbackSuccess(msg, callId);
                                }
                                else {
                                        callbackSuccess(msg);
                                }
                        }
                },
                error: function(xhr) {
                        if (callbackError) {
                                if (callId) {
                                        callbackError(xhr, callId);
                                }
                                else {
                                        callbackError(xhr);
                                }
                        }
                        else if (xhr.responseText) {
                                alert(xhr.responseText);
                        }
                        else {
                                alert("Unknown Server Error.");
                        }
                }
        });
}

WebClient.query = function(data, callbackSuccess, callbackError,
callId) {
        var json = $.toJSON(data);
        var uri = WebClient.ServiceURI + "/QueryV2_Json";
        WebClient.ajaxCall(uri, "POST", json, callbackSuccess, callbackError,
callId);
}

Reply via email to