How can I put 2 operations in my onclick parameter, one calling a Javascript function, the other giving location.href with Django tags ? I want to make something appear on the page before redirecting to another page.
I want to do something like this :
onclick="chargement();location.href='{% url 'resumefic' upload.0.pk %}';"
but my function chargement()
isn't called, only the redirection works.
I can't put the location.href in a JS function as I'm using Django tags... Can someone help ?
The problem is that the redirection occurs before you can see what the chargement
function has done. Try adding a delay before the redirection, for example replace your code with.
onclick="chargement();setTimeout(function(){location.href='{% url 'resumefic' upload.0.pk %}';},1000);"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.