Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果在jQueryDatePicker中使用onSelect,则获取未定义的数据_Javascript_Jquery_Node.js_Datepicker - Fatal编程技术网

Javascript 如果在jQueryDatePicker中使用onSelect,则获取未定义的数据

Javascript 如果在jQueryDatePicker中使用onSelect,则获取未定义的数据,javascript,jquery,node.js,datepicker,Javascript,Jquery,Node.js,Datepicker,我在后端使用nodejs,对于日期选择器,我使用jquery插件 我的结束日期不应该小于开始日期,所以我使用了以下代码 <div class="ipfield"> <label class="plclabel" for="role_type">Start Date</label> <div class='input-group date' id='datetimepicker1'>

我在后端使用nodejs,对于日期选择器,我使用jquery插件

我的结束日期不应该小于开始日期,所以我使用了以下代码

<div class="ipfield">
           <label class="plclabel" for="role_type">Start Date</label> 
            <div class='input-group date' id='datetimepicker1'>
                <input type="text" name="startdate" id="datepicker1" ng-model="userdatas.start_date"  class="txt_box" id="datepicker1" autocomplete="off">

            </div>
          </div>


          <div class="ipfield">
           <label class="plclabel" for="role_type">End Date</label> 
            <div class='input-group date' id='datetimepicker1'>
                <input type="text" id="datepicker2" name="enddate" ng-model="userdatas.end_date"  class="txt_box" id="datepicker2" autocomplete="off">

            </div>
          </div>

  $( function() {
    $("#datepicker1").datepicker({
        changeMonth: true,
        minDate: dateToday,
        changeYear: true,
        dateFormat:'dd-M-yy',
        onSelect: function(selected) {
          $("#datepicker2").datepicker("option","minDate", selected)
        }
    });
    $("#datepicker2").datepicker({
         changeMonth: true,
         changeYear: true,
         dateFormat:'dd-M-yy',
        onSelect: function(selected) {
           $("#datepicker1").datepicker("option","maxDate", selected)
        }
    }); 
});
更新:

我通过angularjs发送请求

var app = angular.module('app', ['countrySelect','ui.bootstrap','angularMoment','msl.uploads','angularFileUpload', 'ngMessages','ngTagsInput','ui-notification','angularUtils.directives.dirPagination']);

app.controller('settingsCtrl', function($scope, $http,$filter,Notification) 

{
     $scope.add_notification = function(msg){
          console.log(msg) // here itself am not getting the value
            $http.post('/add_notification',{'msg':msg}).then(function(response)
                {
                $('#editModal').modal('toggle');
                if(response.data=='error')
                   {   
                  Notification.error('<span class="glyphicon glyphicon-ok"></span><strong>Error !Please Try Again</strong>');   

                   }
                  else
                    {
                 Notification.success('<span class="glyphicon glyphicon-ok"></span><strong>Your news/event is saved and will be visible to all users for the time period choosen.</strong>');    
                    }

                $scope.load_notification();    
                }); 
             }
})
var-app=angular.module('app',['countrySelect','ui.bootstrap','angularmonent','msl.uploads','angularFileUpload','ngMessages','ngTagsInput','ui-notification','angularUtils.dirPagination']);
app.controller('settingsCtrl',函数($scope,$http,$filter,Notification)
{
$scope.add_notification=函数(msg){
console.log(msg)//这里我没有得到值
$http.post('/add_notification',{'msg':msg})。然后(函数(响应)
{
$('#editModal').modal('toggle');
if(response.data=='error')
{   
通知。错误(“错误!请重试”);
}
其他的
{
通知。成功(“您的新闻/事件已保存,并将在所选时间段内对所有用户可见。”);
}
$scope.load_通知();
}); 
}
})
如果我没有使用onSelect,我将获取数据,但我的结束日期不应小于开始日期


我的代码中有错误吗?

onselect
在用户选择(突出显示)输入或文本区域()中的某些文本后发生

onchange
指修改输入或选择元素()


在您感兴趣的更改(更新输入)完成后,您可能会更幸运地使用另一个触发事件。

您如何以及在哪里将请求发送到后端?感谢您的回复,我使用angularjs,我已更新了代码谢谢您的回复,我会试着用onchange谢谢你,我用过onClose。现在工作很好
var app = angular.module('app', ['countrySelect','ui.bootstrap','angularMoment','msl.uploads','angularFileUpload', 'ngMessages','ngTagsInput','ui-notification','angularUtils.directives.dirPagination']);

app.controller('settingsCtrl', function($scope, $http,$filter,Notification) 

{
     $scope.add_notification = function(msg){
          console.log(msg) // here itself am not getting the value
            $http.post('/add_notification',{'msg':msg}).then(function(response)
                {
                $('#editModal').modal('toggle');
                if(response.data=='error')
                   {   
                  Notification.error('<span class="glyphicon glyphicon-ok"></span><strong>Error !Please Try Again</strong>');   

                   }
                  else
                    {
                 Notification.success('<span class="glyphicon glyphicon-ok"></span><strong>Your news/event is saved and will be visible to all users for the time period choosen.</strong>');    
                    }

                $scope.load_notification();    
                }); 
             }
})