Here is my full html context.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test page</title>
<script language="javascript" type="text/javascript" src="jquery-1.5.1.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
开发者_如何学运维 $.getJSON('http://10.10.10.10:8123/BMreport.txt', function (data) {
alert("callback");
});
});
</script>
</head>
<body>
<p>Test Page</p>
</body>
</html>
well the alert doesnt shows up. The BMreport.txt is in JSon format. cannot figure why... --------------solved------------ 10.10.10.10:8123 is different domain from this site. After putting them in same domain it works
Check the console for any errors, or use $.ajax() instead of $.getJSON and supply an 'error'-function. Most likely, something goes wrong when jQuery tries to parse your json.
$(document).ready(function () {
$.ajax({
url: 'http://10.10.10.10:8123/BMreport.txt',
success: function (data) {
alert("callback");
},
error: function(req, err) {
alert(req.responseText); // This will alert whatever your .txt-file outputs
}
});
});
精彩评论