我在哪里可以检查 jQuery 中的语法错误

发布于 2024-10-09 01:32:58 字数 5703 浏览 2 评论 0原文

我想在某处检查我的 jquery 语法。我在哪里可以查到? 我的脚本中出现语法错误,

  $(document).ready(function() 
  {
      var date = new Date();
      var d = date.getDate();
      var m = date.getMonth();
      var y = date.getFullYear();
      var officerid = document.getElementById('officerid').value;
      url = "/TasksToOfficer/Calender/" + officerid; 
      var currenteventIden = <%= serializer.Serialize( ViewData["iden"] ) %>
      var calendar = $('#calendar').fullCalendar
      (
        {
         header: {
                              left: 'prev,next today',
                              center: 'title',
                              right: 'month,agendaWeek,agendaDay',
                              border: 0
                          },

              eventClick: function(event, element) 
              {

              var title = prompt('Event Title:', event.title, { buttons: { Ok: true, Cancel: false} });
              var iden = event.id;
              if (title) 
              {
                  var st = event.start;
                  var ed = event.end;
                  var aldy = event.allDay;
                  var dt = event.date;

                  event.title = title;                        
                  calendar.fullCalendar('updateEvent',event);


                  var date = new Date(st);
                  var NextMonth = date.getMonth() + 1;
                  var dateString = (date.getDate()) + '/' + NextMonth + '/' + date.getFullYear();
                  var QueryStringForEdit=null;

                  QueryStringForEdit="officerid=" + officerid + "&description=" + title + "&date=" + dateString + "&IsForUpdate=true&iden=" + iden;


                  if (officerid) {$.ajax({
                                    type: "POST",
                                    url: "/TasksToOfficer/Create",
                                    data: QueryStringForEdit,
                                    success: function(result) 
                                            {if (result.success) $("#feedback input").attr("value", ""); // clear all the input fields on success
                                            },
                                    error: function(req, status, error) 
                                                {

                                                }
                                 });                                                                        
                                }
              }

          },
          selectable: true,
          selectHelper: true,
          select: function(start, end, allDay) {
                                                  var title = prompt('Event Title:', { buttons: { Ok: true, Cancel: false }}


                                                  );
                                                  if (title)
                                                     {
                                                           calendar.fullCalendar('renderEvent',
                                                           {
                                                               title: title,
                                                               start: start,
                                                               end: end,
                                                               allDay: allDay
                                                           },
                                                            false); // This is false , because do not show same event on same date after render from server side.
                                                           var date = new Date(start);

                                                             var NextMonth = date.getMonth() + 1; // Reason: it is bacause of month array it starts from 0

                                                              var dateString = (date.getDate()) + '/' + NextMonth + '/' + date.getFullYear();

                                                      if (officerid)
                                                       {
                                                          $.ajax({
                                                                        type: "POST",
                                                                        url: "/TasksToOfficer/Create",
                                                                        data: "officerid=" + officerid + "&description=" + title + "&date=" + dateString + "&IsForUpdate=false",
                                                                        success: function(result)
                                                                         {
                                                                          if (result.success) $("#feedback input").attr("value", ""); // clear all the input fields on success

                                                                        },
                                                                        error: function(req, status, error)
                                                                         {

                                                                        }
                                                                    });
                                                      }
                                                  }
                                                  calendar.fullCalendar('unselect');
                                              },
          editable: true,             
          events: url 
      });
  }); // Getting here syntax error

这应该是什么?

I want to check my jquery syntax somewhere. where i can check it ?
I am getting syntax error in my script

  $(document).ready(function() 
  {
      var date = new Date();
      var d = date.getDate();
      var m = date.getMonth();
      var y = date.getFullYear();
      var officerid = document.getElementById('officerid').value;
      url = "/TasksToOfficer/Calender/" + officerid; 
      var currenteventIden = <%= serializer.Serialize( ViewData["iden"] ) %>
      var calendar = $('#calendar').fullCalendar
      (
        {
         header: {
                              left: 'prev,next today',
                              center: 'title',
                              right: 'month,agendaWeek,agendaDay',
                              border: 0
                          },

              eventClick: function(event, element) 
              {

              var title = prompt('Event Title:', event.title, { buttons: { Ok: true, Cancel: false} });
              var iden = event.id;
              if (title) 
              {
                  var st = event.start;
                  var ed = event.end;
                  var aldy = event.allDay;
                  var dt = event.date;

                  event.title = title;                        
                  calendar.fullCalendar('updateEvent',event);


                  var date = new Date(st);
                  var NextMonth = date.getMonth() + 1;
                  var dateString = (date.getDate()) + '/' + NextMonth + '/' + date.getFullYear();
                  var QueryStringForEdit=null;

                  QueryStringForEdit="officerid=" + officerid + "&description=" + title + "&date=" + dateString + "&IsForUpdate=true&iden=" + iden;


                  if (officerid) {$.ajax({
                                    type: "POST",
                                    url: "/TasksToOfficer/Create",
                                    data: QueryStringForEdit,
                                    success: function(result) 
                                            {if (result.success) $("#feedback input").attr("value", ""); // clear all the input fields on success
                                            },
                                    error: function(req, status, error) 
                                                {

                                                }
                                 });                                                                        
                                }
              }

          },
          selectable: true,
          selectHelper: true,
          select: function(start, end, allDay) {
                                                  var title = prompt('Event Title:', { buttons: { Ok: true, Cancel: false }}


                                                  );
                                                  if (title)
                                                     {
                                                           calendar.fullCalendar('renderEvent',
                                                           {
                                                               title: title,
                                                               start: start,
                                                               end: end,
                                                               allDay: allDay
                                                           },
                                                            false); // This is false , because do not show same event on same date after render from server side.
                                                           var date = new Date(start);

                                                             var NextMonth = date.getMonth() + 1; // Reason: it is bacause of month array it starts from 0

                                                              var dateString = (date.getDate()) + '/' + NextMonth + '/' + date.getFullYear();

                                                      if (officerid)
                                                       {
                                                          $.ajax({
                                                                        type: "POST",
                                                                        url: "/TasksToOfficer/Create",
                                                                        data: "officerid=" + officerid + "&description=" + title + "&date=" + dateString + "&IsForUpdate=false",
                                                                        success: function(result)
                                                                         {
                                                                          if (result.success) $("#feedback input").attr("value", ""); // clear all the input fields on success

                                                                        },
                                                                        error: function(req, status, error)
                                                                         {

                                                                        }
                                                                    });
                                                      }
                                                  }
                                                  calendar.fullCalendar('unselect');
                                              },
          editable: true,             
          events: url 
      });
  }); // Getting here syntax error

What should be that ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

jJeQQOZ5 2024-10-16 01:32:58

请参考 JSFiddle

http://jsfiddle.net/

您必须选择 jQuery 版本,然后在 javascript 中输入 jQuery柱子。如果有任何错误,单击 JsLint 按钮将会弹出。

Please refer the JSFiddle

http://jsfiddle.net/

You have to select the jQuery version and then type the jQuery in javascript column. clicking on the JsLint button will pop you if any errors.

国产ˉ祖宗 2024-10-16 01:32:58

您可以在 JSLint 上查看。

You can check it on JSLint.

始于初秋 2024-10-16 01:32:58

Here's the first message I got when entering my code in jsLint:
'$' was used before it was defined. (on http://www.jslint.com/)

On the other hand, jsfiddle (http://jsfiddle.net/) provides a jsHint button (at the header bar) that understands jQuery and neatly flags mistakes. Also the TidyUp button sets the indentation properly! I already used that site but missed those features, now I'll use it much more.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文