I keep receiving an error when viewing the console after calling a Js function from a button
<title>SDMT</title>
<head>
<script language="JavaScript" type="text/javascript" src="js/ping.js"></script>
<link rel="stylesheet" type="text/css" href="css/mystyle.css">
<link rel="stylesheet" type="text/css" href="css/tables.css">
<script language="JavaScript" type="text/javascript" src="js/clock.js"></script>
<body>
<!--clock-->
<div id="clockDisplay" class="clockStyle"></div>
<!--Ping Tool-->
<input id="clickMe" type="button" value="Update Status" onclick="isValidURL()" />
</body>
I have tried putting the ping.js first in the header but this has not resolved the issue, this is my js file:
function isValidURL(url) {
var encodedURL = encodeURIComponent(url);
var isValid = false;
$.ajax({
url: "10.128.128.128",
type: "get",
async: false,
dataType: "json",
success: function(data) {
isValid = data.query.results != null;
},
error: function(){
isValid = false;
}
});
return isValid;
}
If any one has any suggestion that would be awesome, I have cut out all of the other random elements aswell and still recieve this error
Uncaught ReferenceError: $ is not defined
isValidURL @ ping.js:5
onclick @ index.html:124
$.ajax is a Jquery Method. You need to include the Jquery Library into your document.
In your head add this
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.