jQuery上的问题-Javascript提交结束标记

jQuery上的问题-Javascript提交结束标记,javascript,jquery,Javascript,Jquery,请看一下下面的代码,让我知道为什么我不能初始化 $submitform.onclick,函数e{} 我已经试过了,但它没有显示任何不匹配的字符。我花了好几个小时来处理它,但不幸的是,我无法找出是什么导致了这一点。奇怪的是,应用程序运行良好,我在控制台上没有收到任何错误 $("#submitform").on("click", function (e) { $("div.alert").remove(); // Validation var proceed = tr

请看一下下面的代码,让我知道为什么我不能初始化 $submitform.onclick,函数e{}

我已经试过了,但它没有显示任何不匹配的字符。我花了好几个小时来处理它,但不幸的是,我无法找出是什么导致了这一点。奇怪的是,应用程序运行良好,我在控制台上没有收到任何错误

$("#submitform").on("click", function (e) {

     $("div.alert").remove();
     // Validation
     var proceed = true;
     if (targetPower == "Target Energy") {
         $('#counter').parent().after('<div class="alert alert-danger err"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>This is a Requierd Field</div>');
         proceed = false;

     }
     if ($("#scenSelect").val() == "0") {
         $('#counter1').parent().after('<div class="alert alert-danger err"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Please Select From List</div>');
         proceed = false;

     }
     if (proceed) {
         //Change Concat
         targetPower = targetPower.replace(/\D/g, '');
         senario = $("#scenSelect").val();
         var mapquery = senario + "_" + targetPower;
         var data = 'column=' + mapquery;
         if (qtype == "econo") {
             var req = $.ajax({
                 type: "POST",
                 data: data,
                 dataType: 'json',
                 url: "assets/econo.php"
             });

             req.done(function (points) {
                 coords = points;

                 st = map.set();
                 for (var i = 0; i < coords.length; i++) {
                     var circle = map.circle(coords[i][0], coords[i][1], 5);
                     st.push(circle);
                 }
                 st.attr({
                     fill: '#FF6600',
                     translation: "4,4",
                     stroke: '#FFF',
                         'stroke-width': 1.5,
                     opacity: 1,
                 });

                 st.hover(function () {
                     this.animate({
                         fill: 'red',
                         opacity: .6,
                         r: 8,
                             'stroke-width': 2
                     }, 300)
                 }, function () {
                     this.animate({
                         //fill: '#98ED00',
                         fill: '#FF6600',
                         opacity: 1,
                             'stroke-width': 1.5,
                         r: 5
                     }, 300)
                 });
             }); //done first
             var req2 = $.ajax({
                 type: "POST",
                 data: data,
                 dataType: 'json',
                 url: "assets/econocharts.php"
             });
             req2.done(function (data) {
                 var cars = [];
                 cars.push(data[0]);
                 cars.push(data[1]);
                 cars.push(data[2]);
                 cars.push(data[3]);
                 cars.push(data[4]);
                 $('#chart1').highcharts({
                     chart: {
                         type: 'column'
                     },
                     credits: {
                         enabled: false
                     },
                     title: {
                         text: 'Economy Model',
                         style: {
                             color: '#FFF',
                             fontWeight: 'normal',
                             fontSize: '11',
                             marginBottom: '30'
                         }
                     },

                     xAxis: {
                         categories: ['ROR Facilities'],

                     },
                     yAxis: {
                         title: {
                             text: 'Number of Facilities'

                         },
                         tickInterval: 50,
                         max: 300
                     },
                     legend: {
                         enabled: false
                     },
                     tooltip: {
                         formatter: function () {
                             return this.x + '  <b>' + this.y + '</b>';
                         }
                     },

                     series: [{
                         data: [{
                             name: 'Point 1',
                             color: '#00FF00',
                             y: cars[0]
                         }]
                     }]
                 });

                 // Second Chart

                 $('#chart2').highcharts({
                     chart: {
                         type: 'column'
                     },
                     credits: {
                         enabled: false
                     },
                     title: {
                         text: 'title!',
                         style: {
                             color: '#FFF',
                             fontWeight: 'normal',
                             fontSize: '11',
                             marginBottom: '30'
                         }
                     },

                     xAxis: {
                         plotLines: [{
                             color: 'grey',
                             value: '.5',
                             width: '3'
                         }],
                         categories: ['Powerlines', 'Roads'],
                         style: {
                             color: Highcharts.getOptions().colors[0]
                         },
                     },
                     yAxis: [{ // Primary yAxis
                         labels: {
                             format: '{value}',
                             style: {
                                 color: Highcharts.getOptions().colors[1]
                             }
                         },
                         title: {
                             text: 'Km Powerline',
                             style: {
                                 color: Highcharts.getOptions().colors[1]
                             }
                         }
                     }, { // Secondary yAxis
                         title: {
                             text: 'Km Roads',
                             style: {
                                 color: Highcharts.getOptions().colors[0]
                             }
                         },
                         labels: {
                             format: '{value} ',
                             style: {
                                 color: Highcharts.getOptions().colors[0]
                             }
                         },
                         opposite: true
                     }],
                     legend: {
                         enabled: false
                     },
                     tooltip: {
                         formatter: function () {
                             return this.x + ' <b>' + this.y + ' Km</b>';
                         }
                     },
                     series: [{
                         name: 'Powerline',

                         //color: '#0066FF',
                         type: 'column',
                         yAxis: 1,
                         data: [0, cars[2]],
                         tooltip: {
                             valueSuffix: ' km'
                         }

                     }, {
                         name: 'Roads',
                         type: 'column',
                         data: [cars[1], 0],
                         tooltip: {
                             valueSuffix: ' km'
                         }
                     }]
                 });

                 // Third Chart
                 $('#chart3').highcharts({
                     chart: {
                         type: 'column'
                     },
                     credits: {
                         enabled: false
                     },
                     title: {
                         text: 'The Chart Title Goes Here!',
                         style: {
                             color: '#FFF',
                             fontWeight: 'normal',
                             fontSize: '11',
                             marginBottom: '30'
                         }
                     },

                     xAxis: {
                         categories: ['Penstocks'],

                     },
                     yAxis: {
                         labels: {
                             formatter: function () {
                                 return this.value / 1000;
                             }

                         },
                         title: {
                             text: 'Km Penstocks'

                         },
                         tickInterval: 100000,
                         max: 1500000
                     },
                     legend: {
                         enabled: false
                     },
                     tooltip: {
                         formatter: function () {
                             return this.x + '  <b>' + this.y + ' m</b>';
                         }
                     },

                     series: [{
                         data: [{
                             name: 'Point 1',
                             color: '#00FF00',
                             y: cars[4]
                         }]
                     }]
                 });

                 // Four Chart

                 $('#chart4').highcharts({
                     chart: {
                         type: 'column'
                     },
                     credits: {
                         enabled: false
                     },
                     title: {
                         text: 'The Chart Title Goes Here!',
                         style: {
                             color: '#FFF',
                             fontWeight: 'normal',
                             fontSize: '11',
                             marginBottom: '30'
                         }
                     },

                     xAxis: {
                         categories: ['Total Cost Per Year'],

                     },
                     yAxis: {
                         labels: {
                             formatter: function () {
                                 return this.value / 1000000;
                             }

                         },
                         title: {
                             text: 'Million $'

                         },
                         tickInterval: 100000000,
                         max: 1300000000
                     },
                     legend: {
                         enabled: false
                     },
                     tooltip: {
                         formatter: function () {
                             return this.x +
                                 '  <b>' + this.y + '< $/b>';
                         }
                     },

                     series: [{
                         data: [{
                             name: 'Point 1',
                             color: '#00FF00',
                             y: cars[3]
                         }]
                     }]
                 });


             });
         } //end of ecolo

         if (qtype == "ecolo") {
             var add = 'img/' + $("#aniSelect").val() + '.png';

             image2.animate({
                 opacity: 0
             }, 500, mina.easein, function () {
                 image2.remove();
                 image2 = map.image(add, -100, 0, 794, 680).insertBefore(st).animate({
                     opacity: 1,
                     x: 0
                 }, 500, mina.easeout);

             });
             var selectedanimal = $("#aniSelect").val();
             var dataecolo = 'column=' + mapquery + '&animal=' + selectedanimal;
             if ($('#c1').is(':checked')) {
                 var req = $.ajax({
                     type: "POST",
                     data: dataecolo,
                     dataType: 'json',
                     url: "assets/ecolo_yes.php"
                 });

                 req.done(function (points) {
                     coords = points;

                     st = map.set();
                     for (var i = 0; i < coords.length; i++) {
                         var circle = map.circle(coords[i][0], coords[i][1], 5);
                         st.push(circle);
                     }
                     st.attr({
                         fill: '#FF6600',
                         translation: "4,4",
                         stroke: '#FFF',
                             'stroke-width': 1.5,
                         opacity: 1,
                     });

                     st.hover(function () {
                         this.animate({
                             fill: 'red',
                             opacity: .6,
                             r: 8,
                                 'stroke-width': 2
                         }, 300)
                     }, function () {
                         this.animate({
                             //fill: '#98ED00',
                             fill: '#FF6600',
                             opacity: 1,
                                 'stroke-width': 1.5,
                             r: 5
                         }, 300)
                     });
                 }); //done first
                 //Performance

                 var req3 = $.ajax({
                     type: "POST",
                     data: dataecolo,
                     dataType: 'json',
                     url: "assets/ecolochart_yes.php"
                 });
                 req3.done(function (data) {
                     var cuyes = [];
                     cuyes.push(data[0]);
                     cuyes.push(data[1]);
                     cuyes.push(data[2]);
                     cuyes.push(data[3]);
                     cuyes.push(data[4]);
                     $('#chart1').highcharts({
                         chart: {
                             type: 'column'
                         },
                         credits: {
                             enabled: false
                         },
                         title: {
                             text: 'Economy Model',
                             style: {
                                 color: '#FFF',
                                 fontWeight: 'normal',
                                 fontSize: '11',
                                 marginBottom: '30'
                             }
                         },

                         xAxis: {
                             categories: ['ROR Facilities'],

                         },
                         yAxis: {
                             title: {
                                 text: 'Number of Facilities'

                             },
                             tickInterval: 50,
                             max: 300
                         },
                         legend: {
                             enabled: false
                         },
                         tooltip: {
                             formatter: function () {
                                 return this.x + '  <b>' + this.y + '</b>';
                             }
                         },

                         series: [{
                             data: [{
                                 name: 'Point 1',
                                 color: '#00FF00',
                                 y: cuyes[0]
                             }]
                         }]
                     }); // End of Chart One

                     // Third Chart
                     $('#chart3').highcharts({
                         chart: {
                             type: 'column'
                         },
                         credits: {
                             enabled: false
                         },
                         title: {
                             text: 'The Chart Title Goes Here!',
                             style: {
                                 color: '#FFF',
                                 fontWeight: 'normal',
                                 fontSize: '11',
                                 marginBottom: '30'
                             }
                         },

                         xAxis: {
                             categories: ['Penstocks'],

                         },
                         yAxis: {
                             labels: {
                                 formatter: function () {
                                     return this.value / 1000;
                                 }

                             },
                             title: {
                                 text: 'Km Penstocks'

                             },
                             tickInterval: 100000,
                             max: 1500000
                         },
                         legend: {
                             enabled: false
                         },
                         tooltip: {
                             formatter: function () {
                                 return this.x + '  <b>' + this.y + ' m</b>';
                             }
                         },

                         series: [{
                             data: [{
                                 name: 'Point 1',
                                 color: '#00FF00',
                                 y: cuyes[4]
                             }]
                         }]
                     }); //end of Chart 3


                 });
             } //end of if Checked
             else {}
         } // end of ecolo
     } // end of procced
     mapReset();
     e.preventDefault();
 });

如果您在jsfiddle.net上设置一个最小的测试环境,这将非常有用——如果没有附带的标记,这很难理解。另外,在JSON对象中的最后一个标识符后面加逗号是一种不好的做法,就像在opacity:1中一样,因为旧版本的IE将其视为语法错误-可能是这样吗?我无法初始化结束标记意味着什么?另外,如果应用程序工作正常,并且我在控制台上没有收到任何错误,那么问题是什么?是什么让你觉得有问题?@shanet,谢谢你的回复,但在我的上一篇帖子中,我已经尝试过了,人们告诉我这样做!然而,这里是链接@Jason P,正如你所知,如果你点击idle上的结束标记,结束标记也会突出显示,但在这段代码中,这并没有发生,但是我没有收到任何错误,应用程序正在运行。你在说编辑器中的括号匹配吗?有时,由于解析脚本时出现问题,编辑器很难匹配长函数中的方括号。虽然这不是您的代码的错误(语法正确),但这是您应该将提交处理程序分解为更小的函数的标志。