Capture GET and POST with Javascript or Jquery -


is there way capture and/or post request being sent browser server?

i have web app full page refreshes after requests made, , of pages have long response times server due long running queries on database.

so after 1 of these requests made, view made stays visible while browser "waiting response server".

i want add can applied globally capture whenever request made server, , trigger loading spinner run. like:

​window.onclick = function (e) {     if (e.isgetorpost) {         startloadingspinner();     } }​ 

update: not using ajax , post. requests coming hrefs , forms.

since using mvc (the story tagged mvc), easy way see http method of current action, following way easy do:

var httpmethod = "@viewcontext.httpcontext.request.httpmethod"; 

request.httpmethod returns string get, post, delete, etc. text rendered during view rendering only; won't change in ajax scenario, unless update variable.

then can in js:

if (httpmethod == "get" || httpmethod == "post") {    //do } 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -