3

I've been using Dajaxice with my Django based site as it has been very convenient.

However, I sometimes need to cancel the Ajax requests and I don't know how to do it when the requests are wrapped with Dajaxice.

The documentation for Dajaxice is fairly light - I haven't found any reference to canceling Ajax requests using the Dajaxice API.

Has anyone had to deal with this?

Should I abandon Dajaxice and go to jQuery Ajax calls?

Lyndsey Ferguson
  • 5,306
  • 1
  • 29
  • 46

2 Answers2

0

The pull request for this bug returns the underlying XHR object from Dajaxice.call. So you should be able to store a reference to the request object and later call it's .abort method to cancel the request.

That said, if you are using jQuery anyway I would be inclined to use their AJAX calls. jQuery provides a great deal of flexibility at a higher level of abstraction, as opposed to of working directly with the XHR object. But that's your choice.

Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
0

Not sure how viable this answer is for your case, but when I have an out of control Dajaxice call, I just restart Apache2 server, which kills the connection from the page. Then it is happy. If you are wanting to program a way from the user interface, I'm not sure how you would do that.

Furbeenator
  • 8,106
  • 4
  • 46
  • 54
  • Right, this won't be helpful for me: the problem isn't that the calls are out of control, rather a new Dajaxice call will render previous ones irrelevant and I want to cancel them. I haven't seen a lot of people talking about Dajaxice so I'm considering if I want to use the API or not. I may go directly to the rawer jQuery Ajax calls to get the control I want. With those, I can queue up the calls and cancel them... – Lyndsey Ferguson Dec 09 '11 at 13:22
  • Yea, you might be best off using jQuery instead. – Furbeenator Dec 09 '11 at 21:03