简体   繁体   English

如何修复jquery错误TypeError:“单击”调用

[英]how to fix jquery error TypeError: 'click' called

I'm working on a project which is a control panel for minecraft servers, this is the configuration section in this and created a form that the user must complete to make the configuration and to send the values ​​eh used ajax but I get this error : TypeError: 'click' called on an object that does not implement interface HTMLElement. 我正在一个项目中,该项目是Minecraft服务器的控制面板,这是其中的配置部分,并创建了一个表单,用户必须完成该表单以进行配置并发送使用过的Ajax的值,但我明白了错误:TypeError:在未实现接口HTMLElement的对象上调用了“ click”。 How can I solve that I speak Spanish so the document is in Spanish 我该如何解决我说西班牙语,所以文档是西班牙语

 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <!DOCTYPE html> <html lang="en"> <head> <?php $file = "../home/server.properties"; if (file_exists($file)) { $file = file("../home/server.properties"); if (!str_replace("allow-flight=false", "allow-flight=false", $file)) { $fly = "true"; } else { $fly = "false"; } if (!str_replace("force-gamemode=false", "force-gamemode=false", $file)) { $forgm = "true"; } else { $forgm = "false"; } if (str_replace("spawn-npcs=false", "spawn-npcs=false", $file) == true) { $NPCS = "true"; } else { $NPCS = "false"; } if (str_replace("spawn-animals=false", "spawn-animals=false", $file) == true) { $animal = "true"; } else { $animal = "false"; } if (str_replace("online-mode=true", "online-mode=true", $file) == true) { $pirate = "false"; } else { $pirate = "true"; } $file2 = implode('|',$file); if (strpos($file2, "pvp=true") == true) { $pvp = "true"; } else { $pvp = "false"; } if (strpos($file2, "difficulty=0") == true) { $diff = 0; } if (strpos($file2, "difficulty=1") == true) { $diff = 1; } if (strpos($file2, "difficulty=2") == true) { $diff = 2; } if (strpos($file2, "difficulty=3") == true) { $diff = 3; } if (strpos($file2, "enable-command-block=true") == true) { $command_block = "true"; } else { $command_block = "false"; } if (strpos($file2, "gamemode=0") == true) { $gm = 0; } if (strpos($file2, "gamemode=1") == true) { $gm = 1; } if (strpos($file2, "gamemode=2") == true) { $gm = 2; } if (strpos($file2, "spawn-monsters=true") == true) { $criaturas = "true"; } else { $criaturas = "false"; } if (file_exists("../motd12.save")) { $save1 = file("../motd12.save"); $save1 = implode('|',$save1); $save1 = base64_decode($save1); $motd = $save1; $not_exists = 0; } else { $not_exists = 1; $motd = "A Minecraft Server"; } $svp = 1; } else { $svp = 0; } $js = 'var valuesL = ["'.$fly.'","'.$forgm.'","'.$NPCS.'","'.$animal.'","'.$pirate.'","'.$pvp .'","'.$diff.'","'.$command_block.'","'.$gm.'","'.$criaturas.'","'.$motd.'"];'; ?> <?php echo "<script>"; echo $js; echo 'var svp = "'.$svp.'"'; echo "</script>"; ?> <meta charset="UTF-8"> <title>Panel de Control ° Config</title> <script src="https://code.jquery.com/jquery-3.3.1.js"></script> <link rel="stylesheet" href="../Css/estilos.css"> <link rel="stylesheet" href="../demo-files/demo.css"> <link rel="stylesheet" href="../console/static/css/bootstrap.min.css"> </head> <body> <div class="nav_bar"> <div class="content"> <a href="../index.php" class="btn-nav">General</a> <a href="#" class="btn-nav">Configuración</a> <a href="../PlugMods/" class="btn-nav">Plugins / Mods</a> <a href="../log/" class="btn-nav">Log</a> </div> </div> <div class="panel-control"> <span class="titulo-text">Configuraciones </span> <div class="comp"> <div class="save-config"> Permitir volar: <select name="fly" id="fly"> <option value="true">Si</option> <option value="false">No</option> </select> <br> Forzar modo de juego: <select name="forgm" id="forgm"> <option value="true">Si</option> <option value="false">No</option> </select> <br> Spawnear NPCS: <select name="npcs" id="npcs"> <option value="true">Si</option> <option value="false">No</option> </select> <br> Spawnear animales: <select name="animal" id="animal"> <option value="true">Si</option> <option value="false">No</option> </select> <br> Permitir minecraft pirata: <select name="pirate" id="pirate"> <option value="true">Si</option> <option value="false">No</option> </select> <br> Jugador contra jugador: <select name="pvp" id="pvp"> <option value="true">Si</option> <option value="false">No</option> </select> <br> Dificultad: <select name="dificulty" id="dificulty"> <option value="pacifico">Pacifico</option> <option value="facil">Facil</option> <option value="normal">Normal</option> <option value="hard">Dificil</option> </select> <br> Permitir bloque de commandos: <select name="command_block" id="command_block"> <option value="true">Si</option> <option value="false">No</option> </select> <br> Modo de juego: <select name="npcs" id="npcs"> <option value="survival">Survival</option> <option value="creativo">Creativo</option> <option value="aventura">Aventura</option> </select> <br> Generar Criaturas: <select name="criaturas" id="criaturas"> <option value="true">Si</option> <option value="false">No</option> </select> <br> MOTD: <input type="text" id="motd" name="motd" placeholder="Motd del server"> <br> <span class="respuesta"></span> <br> <button class="btn-submit" onclick="mifuncionchingona()" id="btn-submit">Save</button> </div> </div> </div> </body> <script> var dificultades = ["pacifico","facil","normal","hard"]; var gamemodes = ["survival","creativo","aventura"]; $(document).ready(function() { loadnames(); }); // funciones // function loadnames() { $('#fly').val(valuesL[0]); $('#forgm').val(valuesL[1]); $('#npcs').val(valuesL[2]); $('#animal').val(valuesL[3]); $('#pirate').val(valuesL[4]); $('#pvp').val(valuesL[5]); $('#dificulty').val(dificultades[valuesL[6]]); $('#command_block').val(valuesL[7]); $('#gm').val(gamemodes[valuesL[8]]); $('#criaturas').val(valuesL[9]); $('#motd').val(valuesL[10]); } $.get("stat.php", function(data,status) { $('#result').html(data); if (data == "Detenido") { var status = "detenido"; } else { var status = "enlinea"; } }); function mifuncionchingona() { var fly = $('#fly').val(), forgm = $('#forgm').val(), npcs = $('#npcs').val(), animal = $('#animal').val(), piratas = $('#pirate').val(), pvp = $('#pvp').val(), difficulty = $('#dificulty').val(), command_block = $('#command_block').val(), gm = $('#gm').val(), criaturas = $('#criaturas').val(), motd = $('#motd').val(); var values = [fly,forgm,npcs,animal,piratas,pvp,dificulty,command_block,gm,criaturas,motd]; if (status == "enlinea") { $.get('../stop.php', function(data) { }); $.post('save.php', { "fly":values[0], "forgm":values[1], "npcs":values[2], "animal":values[3], "piratas":values[4], "pvp":values[5], "diff":values[6], "command_block":values[7], "gm":values[8], "criaturas":values[9], "motd":values[10] }, function(data, status) { console.log("Esperando "+data); $('.respuesta').html('Los cambios se an realizado con exito, el server se esta reiniciando!'); }); } else { $.post('save.php', { "fly":values[0], "forgm":values[1], "npcs":values[2], "animal":values[3], "piratas":values[4], "pvp":values[5], "diff":values[6], "command_block":values[7], "gm":values[8], "criaturas":values[9], "motd":values[10] }, function(data, status) { console.log("Esperando "+data); $('.respuesta').html('Los cambios se an realizado con exito!'); }); } } </script> </html> 

In the line 在行中

var values = [fly,forgm,npcs,animal,piratas,pvp,dificulty,command_block,gm,criaturas,motd];

the variable dificulty doesn't exist (is misspelled). 变量dificulty不存在(拼写错误)。 This may be cascading and causing your error. 这可能是级联并导致您的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM