【问题标题】:Jquery Post DataJquery 发布数据
【发布时间】:2009-10-24 11:32:25
【问题描述】:

我需要使用链接或图片插入/更新数据

我需要一个如何使用 jquery 调用发布数据的代码!

链接

请帮忙

【问题讨论】:

    标签: jquery ajax post


    【解决方案1】:

    HTML

    <a href="some.asp" class="upload">Link</a>
    <input type="hidden" name="parameter" value="value-to-send" />
    

    代码

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

    您可能还想查看jQuery.com 上的文档,尤其是How jQuery Works 部分。

    【讨论】:

      【解决方案2】:

      查看Jquery-Documentation 并稍后通过附加触发器来更改函数调用,使其看起来像这样:

      HTML:

      <a id="myid" href="javascript:void(0);">My link</a>
      <div id="result"></div>
      

      代码:

          $("#myid").click(function() {
              $.ajax({
                  type: 'POST',
                  url: 'some.asp',
                  success: function(result) {
                      if(result != "false") {
                          $("#result").html(result);  
                      } 
                  }
                })    
          });
      

      (未经测试)

      【讨论】:

      猜你喜欢
      • 2016-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-30
      • 2013-01-08
      • 2012-12-06
      • 2012-08-02
      相关资源
      最近更新 更多