JQuery Post data

I need to insert / update data using link or image

I need some code to call post data using jquery!

<a href = "some.asp" onClick = "someaction, value to send"> Link

Please, help

+2


source to share


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


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







All Articles