0

我正在尝试使用 Bettertooltip 为页面中的所有元素设置标题属性。

我正在从 webmethod 获取信息,但调用不断命中错误函数。

我的 webmethod 用于从 sql server 中提取一些信息并将其序列化回 ajax 成功函数。我究竟做错了什么?

这是我的javascript:

<script>
        $(document).ready(function () {
            var PrevIDs = $('a[alter="add_title"]'); //get all preview noded
            $.each(PrevIDs, function () {
                change_a_title(this);
            });


            $('.tTip').betterTooltip({ speed: 150, delay: 300 });
        });



        function change_a_title(obj) {
            var value1 = obj.id;
            var dataString = JSON.stringify({ e_num: value1 });
            $.ajax({
                type: "POST",
                async: false,
                url: "test_for title.aspx/return_event_details",
                data: dataString,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    //result is an Object() returned from the server, we can use it and get the data from it, result.d has the response data
                    if (result.d) {
                        debugger;
                        var event = JSON.parse(result.d);
//                        var Titles = [" ניסיון ", " מין ", " ימים ", " שעות  "];
//                        var currentTitle = "<table>";
//                        for (var i = 0; i < Grades.length; i++) {
//                            debugger;
//                            currentTitle += "<tr><td style='text-align:center'><b>" + Titles[i] + "</b></td></tr><tr><td><div class='progress_wrapper pink_blue'><span class='pink_blue tooltip'>" + Grades[i] + "%</span><progress value='" + Grades[i] + "' max='100' class='pink_blue'></progress></div></td></tr>";

//                        }
//                        currentTitle += "</table>"
                        obj.title = event["name"];
                    }
                    else {

                    }
                },
                error: function (result) {
                    alert("Error Massage");
                }
            });
            //  debugger; 
            //   obj.title = currentTitle;
            //  obj.attr("title", currentTitle);
        }


    </script>

现在我只检查一个元素:(它被发送到“change_a_title”函数但ajax调用失败):

<form id="form1" runat="server">
    <div>
        <a id="1" alter="add_title">ווקוו</a>
    </div>
    </form>

这是我的方法:

 [WebMethod]
    public static string return_event_details(string e_num)
    {
        dbservices db = new dbservices();

        act_event event1 = db.return_event_by_num(Convert.ToInt32(e_num));


        JavaScriptSerializer jSearializer = new JavaScriptSerializer();
        return jSearializer.Serialize(event1);
    }
4

1 回答 1

0

嗯,sql查询错了,所以报错了。现在它工作正常

于 2013-07-25T11:13:58.227 回答