如何使用Jquery Web服务绑定div

时间:2014-10-21 07:19:40

标签: javascript jquery ajax

Jquery Web服务我需要将json值绑定到div

 $.ajax({
                type: "POST",
                url: "Newdashboard.aspx/finalvalue",              
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(),
                datatype: 'json',
                async: false,
                success: function (data) {
                    if (data.d == '[]') {
                        alert('No Matches found');
                    }
                    else {
                        // here bind div
                    }
                },
                error: function (e) {
                    alert("check once...");
                }
            });

finalvalue方法提供的表仅包含值(如50/90/33)

我需要绑定到具有该结果的div,我该怎么做呢。

2 个答案:

答案 0 :(得分:1)

            success: function (data) {
                if (data.d == '[]') {
                    alert('No Matches found');
                }
                else {
                    //  here you amend the data from service.
                    $("div#divId").html(data.d);
                }
            }

jQuery HTML用于解决方案,请检查。

答案 1 :(得分:0)

您可以使用jQuery函数.append()。这会将结果添加到div的末尾。

http://api.jquery.com/append/