How to keep an $.ajax connection open in order to retrieve data regularly from server?

How to keep an $.ajax connection open in order to retrieve data regularly from server?

Hi all,

I've used jQuery.ajax function to request data from AJAX-enabled WCF service. Please look at the following code. It seems that poll function opens a new connection for each jQuery.ajax call because IIS server is not responding after 10 connections (ajax call) although one web page is opened on browser. How to keep an $.ajax connection open in order to retrieve data regularly from server?

Thanks a lot for your helps and clarifications,

  1.         function poll(urlString, data, fnSuccess, fnError) {
                $.ajax({
                    type: "GET",
                    url: urlString,
                    data: data,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: fnSuccess,
                    error: fnError,
                    complete: function (xhr, status) {
                        poll(urlString, data, fnSuccess, fnError);
                    },
                    timeout: 10000,
                    dataFilter: function (data) {
                        var response;

                        // CHECK whether the current browser supports JSON parsing natively
                        if (typeof (JSON) !== "undefined" && typeof (JSON.parse) === "function") {
                            response = JSON.parse(data);
                        }
                        else {
                            response = val("(" + data + ")");
                        }

                        //  CHECK whether the response is enclosed within a ‘d’ property
                        //  NOTE:‘d’ property is added automatically by Microsoft’s WCF service
                        if (response.hasOwnProperty("d")) {
                            return response.d;
                        }
                        else {
                            return response;
                        }
                    }
                });
            }