如何从Jquery中的类对象获取数据 [英] How Can I Get Data From Class Object In Jquery

查看:286
本文介绍了如何从Jquery中的类对象获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码背后



Behind Code

public class Employee
        {



            public string Subject { get; set; }


            public string SrvcRef { get; set; }
        }
        

     [WebMethod]

    public static List<employee> GetEmployee(string ID)
    {
        

          
           
            SqlCommand cmd = new SqlCommand("....");   
        
            GetData.con.Open();
        List<employee> employees = new List<employee>();

        SqlDataReader dr = cmd.ExecuteReader();
         
         
        while (dr.Read())
        {
            var employee = new Employee
            {
                Subject = dr["Subject"].ToString(),
                SrvcRef = dr["SrvcRef"].ToString()

            };
            employees.Add(employee);
        }  
        //Close Connection
        dr.Close();
        GetData.con.Close();
        return employees;
       

        }



J查询




J query

$(document).on("click", "#LoadLocalDialog1", function () {

                    var ID = $("#<%=grdExiRequest.ClientID %> tr").find("td:eq(0)").html();



                    PageMethods.GetEmployee(ID, onSucess);




                    function onSucess(result) {

                        var speed = $(result).data("Subject");


                    }

                    $("#LocalDialogModal").dialog("open");


                });







我需要得到jquery中提交的数据'Subject'。请帮助

推荐答案

document )。on( click #LoadLocalDialog1 function (){

var ID =
(document).on("click", "#LoadLocalDialog1", function () { var ID =


#<%= grdExiRequest.ClientID%> tr)。find( td:eq(0))。html();



PageMethods.GetEmployee(ID,onSucess);




function onSucess(result){

< span class =code-keyword> var speed =
("#<%=grdExiRequest.ClientID %> tr").find("td:eq(0)").html(); PageMethods.GetEmployee(ID, onSucess); function onSucess(result) { var speed =


(result).data( 主体);


}
(result).data("Subject"); }


这篇关于如何从Jquery中的类对象获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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