I am trying to call a python function by Ajax. I want to stop the execution of that function. I have tried to refresh the page but it doesn't stop. When I stopped the Django server then it get stop.
Here some code: This Call call HTTP request
class ScrapData():
@classmethod
def search_status(self, urls_list):
for url in urls_list:
r = requests.get(url)
text = r.text
#...
return 1
Calling this view by Ajax
class SearchData(View):
def get(self, request, *args, **kwargs):
urls_list = [];
response = ScrapData().search_status(urls_list)
return HttpResponse(response)
I want to stop the function. How can I do this? Thanks