-2
$(document).ready(function () {
    $("#Result").click(function () {
        $.ajax({
            type: "POST",
            url: "AjaxJquery.aspx/GetDate",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                alert(msg.d);

            }
        });
    });
}); 

<span id="SpanID"></span>
<input type="button" value="Click" id="Result" />

我想在 span 中显示数据,现在它显示一条警报消息

4

2 回答 2

2
 $(document).ready(function () {

            $("#Result").click(function () {
                $.ajax({
                    type: "POST",
                    url: "AjaxJquery.aspx/GetDate",
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg) {
                        $('#your_span_id').text(msg.d);

                    }
                });
            });
        });
于 2013-06-25T09:17:13.303 回答
0

尝试这个,

$("#Result").click(function () {
        $.ajax({
                type: "POST",
                url: "AjaxJquery.aspx/GetDate",
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    $("#SpanID").html(msg.d);
                }
        });
 });
于 2013-06-25T09:42:59.960 回答