<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="script/jquery-3.2.1.min.js"></script>
<script>
$(function(){
$("#send").click(function(){
$.get("get1.txt",
{
username:$("#username").val(),
content:$("#content").val()
},
function(data,textStatus){
$("#resTest").html(data);
}
)
})
})
</script>
</head>
<body>
<form id="form1" action="#">
<p>评论</p>
<p>姓名:<input type="text" name="username" id="username"/></p>
<p>内容:<textarea name="content" id="content" rows="2" cols="20">
</textarea></p>
<p><input type="button" id="send" value="提交"/></p>
</form>
<div id="resTest"></div>
</body>
</html>
如同上面的代码,在浏览器出现了跨源错误,请问是什么原因呢?
繁星点点滴滴
相关分类