How to open a link and send to it a post request?
Hi to all!
I was guessing if it was possible, using jQuery, to have a link that, when clicked, opens the relative url and sends to it a post request.
I'm trying to do this with the $.post function, but i found the problem that the request is sent, but the page isn't opened.
This is my code:
-
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>-->
<script type="text/javascript">
$(document).ready(function(){
$("a").click(function(event) {
event.preventDefault();
$.post("passdataj2.php", {"name":"myName"});
})
})
</script>
</head>
<body>
<a href="#">Link to passdataj2.php passing a POST request</a>
</body>
</html>