此代码不会在jquery-3.1.0.js上运行

时间:2017-02-15 05:11:41

标签: javascript jquery jquery-3

有没有理由为什么这个代码不会在本地运行的JS 3.1.0上运行(从http://jquery.com/download/下载)但是当我从http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js

加载它时运行正常
<script>
$(window).load(function() {
$(".se-pre-con").fadeOut("slow");;
});
</script>

我很困惑......请帮忙......

2 个答案:

答案 0 :(得分:1)

您在此处使用的jQuery http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js使用jQuery 1.6.1 ,而您从https://jquery.com/download/下载的jQuery使用jQuery <强> 3

在jQuery 3 here的文档中,它说:

  

中断更改:.load(),. unload()和.error()已删除

因此,您可以像.load()一样使用$(function() {});而不是$(function() { // insert code here... });

<?php
session_start();
?>
<html>
<body>
    <h1>User Login Form - PHP MySQL Login System</h1>
    <?php
    if (!isset($_POST['submit'])){
    ?>
    <!-- The HTML login form -->
    <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
        Username: <input type="text" name="username" /><br />
        Password: <input type="password" name="password" /><br />
        <input type="submit" name="submit" value="Login" />
    </form>

    <?php
require_once("settings.php");
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
# check connection
if ($mysqli->connect_errno) {
echo "<p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>";
exit();
}

$username = $_POST['username'];
$password = sha1($_POST['password']);

$sql = "SELECT * from Users WHERE username LIKE '{$username}' AND password LIKE '{$password}' LIMIT 1";
$result = $mysqli->query($sql);
if ($result->num_rows == 1) {

#update the logged_in value here
$sql2 = "UPDATE Users SET logged_in = 1 WHERE username = '$username'";

$location = "contacts.php";
header("Location: $location");
} else {
$location = "login.php";
header("Location: $location");
}
}
?>
</body>
</html>

答案 1 :(得分:1)

在Jquery 3.0版中删除了load()方法。

检查此链接以获取有关Jquery 3.0版的更多更改 https://jquery.com/upgrade-guide/3.0/#breaking-change-load-unload-and-error-removed