0

I have a page that needs to give some file for download based on enetered parameters. Binary file is generated on webservice and I use following way to generate it and give to user.

document.location.href = MyServiceUrl?req=someAction

That works well, however when webservice requested it also generates some update in DB (in addition to file generation). When update is made I need to refresh data at my page (I use ajax). The question is: How can I catch a moment when webservice finish working (changes already in DB) and gives me a file to let me know that it's a time to make refresh?

Roman
  • 391
  • 2
  • 4
  • 17
  • Did you try web sockets? – David Hellsing Mar 14 '13 at 12:13
  • So when the callback is returned you do `window.location.reload(true);` ? – epascarello Mar 14 '13 at 12:15
  • @David No, I need something more simple. I suppose that I can use ajax also and use onsuccess event for catch it but not sure how exactly make it for stream output. – Roman Mar 14 '13 at 12:15
  • @epascarello No, I do not refresh page, I use ajax for refresh one table. – Roman Mar 14 '13 at 12:16
  • It sounds like a typical web sockets scenario. There are alternatives or fallbacks that you can use, like long-pulling ajax etc. I would start looking into normalization libs like socket.io for a simple API. – David Hellsing Mar 14 '13 at 12:22

0 Answers0