未被捕获的ReferenceError:在HTMLButtonElement.onclick上未定义do

编程入门 行业动态 更新时间:2024-10-28 08:26:11
本文介绍了未被捕获的ReferenceError:在HTMLButtonElement.onclick上未定义do_login的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用PHP,AJAX和MySql开发一个简单的登录页面.经过长时间的努力,我做到了:

I am trying to develop a simple login page , using PHP , AJAX and MySql. And after a long struggle , I did this :

<head> <link rel="stylesheet" type="text/css" href="css\\login.css"> <script src="ajax.googleapis/ajax/libs/jquery/1.11.1/jquery.min.js"> function do_login() { var username=$("#username").val(); var pass=$("#password").val(); if(email!="" && pass!="") { $.ajax ({ type:'post', url:'serveur.php', data:{ do_login:"do_login", username:username, password:pass }, success:function(response) { if(response=="success") { window.location.href="index.php"; console.log(1); } else { alert("Wrong Details"); console.log(0); } } }); } else { alert("Please Fill All The Details"); } return false ; } </script> </head> </style> <body> <div class="login-page"> <div class="form"> <form class="login-form"> <input type="username" placeholder="username" id="text" /> <input type="password" placeholder="password" id="password" /> <button type="submit" id="loginButt" onclick="do_login()">login</button> <p class="message"><a href="1stPage.html">Go Back</a></p> <div id="resultat ">Authentification result Here ....</div> </form> </div> </div> </body>

但是我有此错误消息:

未捕获的ReferenceError:在HTMLButtonElement.onclick上未定义do_login

Uncaught ReferenceError: do_login is not defined at HTMLButtonElement.onclick

推荐答案

您的< script> 标记同时具有主体和 src 属性.

Your <script> tag has both a body and a src attribute.

<script src="ajax.googleapis/ajax/libs/jquery/1.11.1/jquery.min.js"> // This is the body of the script tag function do_login() { //... } </script>

< script> 标记的 src 属性优先于标记的主体(请参见 JavaScript:具有SRC属性的内嵌脚本?).因此,这意味着实际上从未定义您的 do_login 函数:(

The src attribute of the <script> tag has precedence over the body of the tag (see JavaScript: Inline Script with SRC Attribute?). So this means your do_login function is never actually being defined :(

尝试将其更改为

<script type="text/javascript" src="ajax.googleapis/ajax/libs/jquery/1.11.1/jquery.min.js" /> <script type="text/javascript"> function do_login() { //... } </script>

更多推荐

未被捕获的ReferenceError:在HTMLButtonElement.onclick上未定义do

本文发布于:2023-11-23 03:41:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619955.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未被   未定义   HTMLButtonElement   ReferenceError   onclick

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!