我正在尝试从jQuery发起$.get()
调用,但是我得到的只是以下错误;
Uncaught TypeError: $.get is not a function
at HTMLDocument.<anonymous> (client.js:12)
at l (jquery.min.js:2)
at c (jquery.min.js:2)
我已经搜索了所有内容,但似乎找不到答案。我正在使用Google CDN导入jQuery。 (https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
)
最小示例
$(document).ready(function() {
jQuery.get('echo/authstatus', function(data) {
console.log(data);
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
完整代码段
let denied = `<div class="alert alert-danger" role="alert">
<strong>Access Denied!</strong> Please check your username and password, then try again.
</div>`;
let granted = `<div class="alert alert-success" role="alert">
<strong>Access Granted!</strong> Welcome, please wait while we redirect you.
</div>`;
let disabled = `<div class="alert alert-warning" role="alert">
<strong>Authentication disabled!</strong> Sorry, we have temporarily disabled authentication!
</div>`;
$(document).ready(function() {
jQuery.get('echo/authstatus', function(data) {
console.log(data);
});
});
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<meta charset="UTF-8">
<title>Echo Login System</title>
<style>
.ubuntu {
font-family: 'Ubuntu', sans-serif;
}
</style>
<script src="client.js"></script>
</head>
<body class="bg-dark">
<div class="jumbotron bg-dark">
<h1 class="display-4 text-info">Echo Login System</h1>
<p class="lead text-white-50">A JavaScript login system, by Eton.</p>
<hr class="my-4 bg-info">
</div>
<div class="container" id="display">
</div>
<div class="container shadow" style="width:24rem">
<h5 class="ubuntu text-info" style="padding-top: 1%">Authentication Required!</h5>
<form>
<div class="form-group">
<input type="text" class="form-control ubuntu" id="username" placeholder="Username">
</div>
<div class="form-group">
<input type="password" class="form-control ubuntu" id="password" placeholder="Password">
</div>
<button id="login" class="btn btn-info" style="margin-top:1%;">Login</button>
</form>
<br>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"
integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"
integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k"
crossorigin="anonymous"></script>
</body>
</html>
答案 0 :(得分:1)
您应该删除底部的第一个脚本标签
Dim arr1 As New List(Of String)
arr1.AddRange(IO.File.ReadAllLines("text file 1"))
Dim arr2 As New List(Of String)
arr2.AddRange(IO.File.ReadAllLines("text file 2"))
Dim searchstring As String = "test1"
'You can replace test1 with the string you are searching the text file for
Dim index1 As Integer = 0
Dim index2 As Integer = 0
'Getting the index of the string in the list
'*******************************************
For x As Integer = 0 To arr1.Items.Count - 1
If arr1(x).StartsWith(searchstring) Then
index1 = x
End If
Next
For x As Integer = 0 To arr2.Items.Count - 1
If arr2(x).StartsWith(searchstring) Then
index2 = x
End If
Next
'*******************************************
Dim split1() As String = Split(arr1(index1), ",")
Dim split2() As String = Split(arr2(index2), ",")
Dim sum As Integer = Integer.Parse(Trim(split1(1))) + Integer.Parse(Trim(split2(1)))
'Writing the sum to another test file, the "output.txt" file would be created on your desktop, you can replace the path's string with your custom location
Dim path As String = Path.Combine(My.Computer.FileSystem.SpecialDirectories.Desktop, "output.txt")
Dim finaltext As String = searchstring + "," + sum.ToString
System.IO.File.AppendAllLines(path, finaltext)
当您在完整版之后加载精简版并覆盖$ .get