为什么我的返回ajax调用给了我两个datepicker输入框?

时间:2014-06-01 19:39:40

标签: javascript asp.net ajax

我正在进行ajax调用,并且已恢复的数据位于div容器中。当用户从日期选择器中选择日期时进行调用。返回数据时,我在表单上有两个数据缓冲区的输入框。我只想在表格上找一个。为什么我的返回ajax调用给了我两个数据输入框输入框?

这是显示数据的部分视图。这是我尝试放在表单顶部和底部的脚本。

<script type="text/javascript">
    $(document).ready(function () {
        $("#datep").datepicker({ 
            showOn: "both", 
            buttonText: "Select Date",
            changeMonth: true, 
            changeYear: true, 
            yearRange: "-2:+2", 
            showOtherMonths: true, 
            onSelect: function (date, datepickder) {
                var sltdDate = { selectedDate: date };
                $.ajax({
                    type: "GET",
                    url: "/Schedule/GetSchedule",
                    data: sltdDate,
                    datatype: "html",
                    success: function (data) {
                        $("#returnedData").html(data);
                    }
                });
            }
        });
     });
 </script>

 <div id="returnedData">

     @if (Model.Assignments != null) {
        //table header here

        @foreach (var item in Model.Assignments.Select((x, i) => new { Data = x, Index = i })) {
            // @Html.DisplayFor(modelItem => item.Data)
            //More item data here    
        }
    }
</div>

<div class ="ui-widget" >
    <label for ="datep">Date: </label><input id="datep" />
</div>

1 个答案:

答案 0 :(得分:0)

返回的ajax调用将另一个日期输入字段放入保存返回数据的容器中。我通过添加$(&#34; #returnedData#dateContainer&#34;)来解决它.remove();成功的功能。