开发者

How to pass an asp.net control to a jQuery ajax call?

开发者 https://www.devze.com 2022-12-29 09:17 出处:网络
I have the following jQuery event that gets fired every time an anchor is clicked.How can I pass a asp.net control (lets say a panel called \"pnl_info\") as one of the parameters, in addition to the \

I have the following jQuery event that gets fired every time an anchor is clicked. How can I pass a asp.net control (lets say a panel called "pnl_info") as one of the parameters, in addition to the "target" parameter i'm already passing?

<script 开发者_开发百科type="text/javascript">
    $(document).ready(function() {
        $("a").click(function(event) {
            $.ajax({
                type: "POST",
                url: "Default.aspx/Click",
                data: "{target:'" + event.target + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                error: function(xhr, ajaxOptions, thrownError) {
                alert(xhr.responseText);
                    $("#myContent").html(xhr.statusText);

                    //alert(xhr.responseText);
                },
                success: function(msg) {
                    alert(msg.d);
                }
            });
            return false;
        })
    })
</script>


Could you do something like...

data: {target: event.target, info: $("#pnl_info").val()}
0

精彩评论

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