使用html a标签发送帖​​子数据 [英] Sending post data using html a tag

查看:145
本文介绍了使用html a标签发送帖​​子数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用html标签发送POST数据。
我知道没有办法这样做,除非我的脚本。
但我尝试,但不能让它工作。

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>    

我尝试使用:

function assign(){ 
            $.post("/Accounts/index", 
            { data: "test" 


            });
        }    

我也尝试过:

$(document).ready(function(){

            $(".test").click(function(){

                $.post("/accounts/index", 
                { data: "test"

                });
            });

        });


推荐答案

尝试:

$(".test").click(function () {
    $.ajax({ url: 'http://.....your path...../accounts/index',
        data: {test:1},
        type: 'post',
        success: function(output) {
            //your code
                 }
            }); 
});

这篇关于使用html a标签发送帖​​子数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆