2

I'm using jqgrid plugin in my project. It has loadComplete event with this description:

loadComplete: This event is executed immediately after every server request. Paramers: data - Data from the response depending on datatype grid parameter.

This event has only data as the parameter, but I need xhr(an instance of XmlHttpRequest) in this event. In fact, I need to access XmlHttpRequest instance immediately after every server request. How can I do this?

hamed
  • 7,939
  • 15
  • 60
  • 114

1 Answers1

0

Please post the version of jqGrid and the fork (free jqGrid, Guriddo jqGrid JS or an old jqGrid in version <=4.7), which you use in all your questions about jqGrid.

The callback loadComplete will be executed after the response is get from the server, the response is parsed, the current page is filled and the other data for the next pages (in case of usage loadonce: true option) are saved locally too. Thus you should use either beforeProcessing or loadBeforeSend or loadError to access to jqXHR object which is jQuery extension to XMLHttpRequest.

There are different scenarios when you could need to access jqXHR:

  • The callback loadBeforeSend can be used for example to set some custom HTTP headers in the request sent to the server. See the answer for the typical code example.
  • beforeProcessing can be used to examine the server response and to modifying the data before there will be processed .
  • One want to test whether there are exist pending Ajax request and to abort it for example. Free jqGrid saves the jqXHR object of the pending request to internal jqXhr parameter. One can use abortAjaxRequest method to abort it. The internal jqXhr parameter will be cleared (set to null) directly at the beginning of success processing.

If I understand your question correctly, then you can use jqXhr parameter directly after sending the Ajax request to the server. I'm developer of free jqGrid fork, thus I can recommend it to you. The current version of free jqGrid is 4.11.1. You can test it by modifying URLs of jqGrid to the URLs described in the wiki article.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798