开发者

Jquery Post Data

I need to insert/update data by using link or image

I need a code ho开发者_如何学JAVAw to call post data using jquery !

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

Please help


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 might also want to check out the documentation at jQuery.com, especially the section on How jQuery Works.


Have a look in the Jquery-Documentation and change the function call by attaching the trigger later, so that it looks this-alike:

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);  
                } 
            }
          })    
    });

(untested)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜