多分これを試してみてください:
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns ="http://www.w3.org/1999/xhtml">
<head>
<title> first_demo </title>
</head>
<body>
<p>click to on </p>
<input type="button" id="submit" value="submit" />
<!--your ajax script comes here-->
</body>
</html>
JAVASCRIPT
$("#submit").click(function(){
$.ajax({
type: "GET",
url: "hostname/filename.txt",//your url here
data: {
//Additional data
},
dataType: 'html/text',
success: function(response) {
console.log("success: " + response);
},
error: function(response) {
console.log("error: " + response);
}
});
});
1)あなたのスクリプトは '頭部 'にあるか、'