I would like to send POST data using an html tag. I know that there is no way doing this unless i script. However i tried , but couldn't get it to work.
<a class="test" onClick="assign()"><img src='<?php echo $accounts[$i]['Account']['image']; ?>' /> <?php echo $accounts[$i]['Account']['screen_name']; ?></a>
I tried using this:
function assign(){
$.post("/Accounts/index",
{ data: "test"
});
}
and i also tried this :
$(document).ready(function(){
$(".test").click(function(){
$.post("/accounts/index",
{ data: "test"
});
});
});
Try this :
$(".test").click(function () {
$.ajax({ url: 'http://.....your path...../accounts/index',
data: {test:1},
type: 'post',
success: function(output) {
//your code
}
});
});