单击Javascript / Jquery将项添加到列表中

时间:2014-03-29 11:48:08

标签: javascript jquery

所以我有一个动态创建的列表,如图所示

现在我需要一个ADD按钮,点击它会自动添加新项目列表。请帮帮我。

1 个答案:

答案 0 :(得分:-1)

Hi this is how can you retrive data using jquery


 $(document).ready(function () {

 $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "URL/MethodName",
                data: "{}",// you can provide parameteres to your function here
                dataType: "JSOn",
                success: function (data) {
                     for (var i in data) {
                alert(data[i].Id); //assign to controls 
                  alert(data[i].Header);// assign to controls 
                  alert( data[i].Content) ;// assign to contols
            }

                   alert('Data fetched Successfully');



                },
                error: function (result) {
                  alert('Data not fetched ');

                    return false;
                }

            });
    return false;
 });


/*************************************************************************
[System.Web.Services.WebMethod]
public ActionResult Careers()
    {
        List<JobOpening> job = new List<JobOpening>()
        {

        new JobOpening{Id = 1, Header = "Job1", Content = "edde" },
        new JobOpening{Id = 2,Header = "Job2", Content = "deded" },

        };



    }