I have a client / service.
The service has a method that takes a lot of time (it interacts with the database).
I call this method with an AJAX request from the page to the client, then to the service and back.
My service code:
[WebMethod] public static string LookupUPC(string sessionId, string upc) { string response = ""; var client = new SmartShopService.SmartShopInterfaceClient(); try { response = client.LookupUPC(sessionId, upc); } catch (Exception e) { throw e; } finally { if (client.State == System.ServiceModel.CommunicationState.Faulted) client.Abort(); else client.Close(); } return response; }
It is called from the page at the request of AJAX
for(var i = 0;i<10; i++){ $.ajax({ type: "POST", url: "SmartShopGUI.aspx/LookupUPC", contentType: "application/json; charset=utf-8", data: DataCreator(allData), dataType: "json", success: function (result) { $(upcName).html(result.d); }, error: AjaxFailed }); }
This now runs asynchronously on the page, but the client sends requests synchronously. I want to change it so that if it requests all 10 at the same time, it will send 10 different requests to the service.
http://www.screencast-o-matic.com/watch/cX1Qo8qV2
Here is a video that might help.
source share