在脚本中,数据来自服务器但未初始化为变量

时间:2016-07-05 06:46:33

标签: javascript jquery

<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        var _dateFormat = '';
        _dateFormat = '<%= WebUI.Models.WebConfigKeys.DateFormat %>';

        var dateArray = '<%= ViewData["CompareCollectionDateSvc"] %>';
        var enabledDays = new Array();
        enabledDays = dateArray.split(",");
        var _firstVal = enabledDays[0];
        var _LastVal = enabledDays[4];

        GetCalederLoad(_firstVal, _LastVal, _dateFormat);

        function GetCalederLoad(startDt, endDt, dtFormat) {
            if (dtFormat != undefined && dtFormat != "")
                dtFormat = dtFormat.toLowerCase();

            $("#drpNewCollectionDateSvc").datepicker({
                autoclose: true,
                clearBtn: true,
                startDate: startDt, // '(System.Web.Mvc.SelectList)(ViewData["CollectionDate"]).First();', //firstarrdate,
                endDate: endDt, // '(System.Web.Mvc.SelectList)(ViewData["CollectionDate"]).Last();',// lastarrdate,
                format: dtFormat,
                daysOfWeekDisabled: [0, 6],
                Default: false,
                beforeShowDay: function (Date) {
                    var curr_date = Date.toJSON().substring(0, 10);
                }
            });
        }

    });
</script>

在这个脚本中,我从ViewData或WebConfig中的服务器获取数据,但它没有被设置为其他变量。我收到一个错误:

  

姓名&#34; _dateformat&#34;在当前上下文中不存在

1 个答案:

答案 0 :(得分:0)

您的输出如下:

SELECT * 
  FROM table AS p 
  LEFT 
  JOIN meta AS m 
    ON m.p_id = p.ID 
   AND m.key = 'poo'
 WHERE m.value IS NULL

然后您可以使用以下内容:

&#13;
&#13;
var dateArray = '07/05/2016,07/06/2016,07/07/2016,07/08/2016,07/11/2016';
&#13;
&#13;
&#13;