I’m trying to ping a server after an interval using jquery. I found jquery ajax function on internet working for so many people but it throws exception
“Access to restricted URI denied” code: “1012”” in Firefox, Errorcode 0 in IE and 404 Chrome for http://www.google.com. I don’t understand what is the problem. Following is my code.
<html>
<head>
<title>Server availability</title>
<script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
var req = function () {
count = count + 1;
var link = $('#testURL').val();
$.ajax({
url: testURL,
success: function () {
$('#spnStatus').html($('#spnStatus').html() + '<br/><br/>' + link + ' Checked ' + count + ' times. Server available');
},
error: function (xhr, ajaxOptions, thrownError) {
//alert(xhr.status + "\n" + thrownError);
$('#spnStatus').html($('#spnStatus').html() + '<br/><br/>' + link + ' Checked ' + count
+ ' times. Server not available. Error Code:' + xhr.status + "<br/> Exception:" + thrownError);
}
});
//Call it again.
setTimeout(function () {
req();
}, 5000);
};
var count = 0;
$(document).ready(function () {
req();
});
</script>
</head>
<body>
<input id="testURL" type="text" value="http://www.google.com" /><br />
<span id="spnStatus">Not checked yet.</span>
</body>
</html>
Thanks in Advance.
Gaby aka G. Petrioli Thanks you’r second comment is the answer for me. 🙂