JQuery Post data
2 answers
Html
<a href="some.asp" class="upload">Link</a>
<input type="hidden" name="parameter" value="value-to-send" />
code
$(function() {
$('.upload').click( function() {
$.post( $(this).attr('href'),
$(this).next('input[type=hidden]').serialize(),
function(data) { do something with returned data } );
return false; // cancel link default action
});
});
You can also check the documentation at jQuery.com , especially the section How jQuery works .
+4
source to share
Have a look at the Jquery-Documentation and change the function call by adding a trigger later so that it looks like this:
HTML:
<a id="myid" href="javascript:void(0);">My link</a>
<div id="result"></div>
code:
$("#myid").click(function() {
$.ajax({
type: 'POST',
url: 'some.asp',
success: function(result) {
if(result != "false") {
$("#result").html(result);
}
}
})
});
(unverified)
+1
source to share