Similar to HTML anchor link - href and onclick both? post, mine is:
<a href="/tmp/download.mp3" onclick="update();">Download link</a>
The update()
method would send another HTTP GET method to the server to update the which file has been downloaded and update the database. From the HTML code, there are 2 GET requests being triggered together and only ONE will get the response (the href download response) from the server. The update()
is not being executed. Is there any method that i can get both GET methods to be executed? Javascript and Jquery suggestions are welcomed!
Forget about the
href
and just do it all in the click function. You can navigate to another page after the update is complete. Here is my JQuery suggestion:HTML
JavaScript (with JQuery)
NOTE: I added in an
id
for thea
tag to ensure it can be selected accurately via JQuery