Reputation: 3
i have one question about jquery ajax().. I created a table grid and there is requirement to skip between cells with a tab key. The grid is constructed so that there is need to call ajax twice (for save the previous cell and show input in the second). My issue is, that when someone is editing cells using tab, there is sometimes very slow response. Normal reponse is about 40-70ms and then in the same case is response longer than 1 second.. Why this is? It seems to me, that the server is not paying attention, because this problem occurs more often when there is delay in editing current cell.. Long response is not caused by type of data edited or samething like that.. It looks like that it is totally random.. I dont want to remake the grid, because everything works well except this problem... Thank you!
Upvotes: 0
Views: 2643
Reputation: 2574
I see two potential approaches for you to solve this problem.
Modularity. If you can, isolate the grid into a sandbox prototype, where nothing else is implemented except what you need to reproduce the error. This is easy if your code is modular, potentially impossible if it is not.
A second way to isolate behavior, is to actually disconnect from the server. Here is what I mean: it is possible to modify your ajax to simply return a 'mocked' object. This way you know that there is no latency or unexpected data type. The notion is called 'data-mocking' and is similar to a Test Driven Development setup. This will prove, for you, if something is awry in request response callback. But, I don't think it is.
Events. For some reason your description sounds like it may be event related. Isolating your grid into a prototype may unexpectedly solve this, if something is being clobbered. So here is my advice in this scenario:
A. Test the error case cross browser. Events can behave differently in different browsers. This may give you a hint to the root cause.
B. Step-Debug your code. If a flurry of events are being produced, or if another handler is stepping in when it shouldn't - your best bet is to catch it in the act at runtime.
C. Chrome, right-click, inspect element, scripts tab, and set breakpoint is a powerful workflow to help solve this.
D. There is a common case with custom events that need to stopPropagation() or preventDefault() that will separate additional event actions from chaining along the DOM stack of handlers. This may or may not be the case for you, the reason that I mention it is that - when I've encountered it in the past, it initially looks random and difficult to reproduce. Here is a link to this information on MDN.
Hope that helps! Nash
Upvotes: 1