Cross-Origin Resource Sharing 跨域资源共享
www.testaaa.com
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="jquery.1.12.min.js"></script>
<script>
$(function(){
$("button").click(function(){
var username=$('#username').val();
$.ajax({
type:'get/post',
url:'http://www.testbbb.com/info.php',
data: {username:username},
success:function(res){
alert(res);
}
})
});
})
</script>
</head>
<body>
<center>
<table border="1">
<tr>
<td><input type="text" name="username" id="username"/></td>
</tr>
<tr>
<td colspan="2"><button>submit</button></td>
</tr>
</table>
<div id="box"></div>
</center>
</body>
</html>
www.testbbb.com/info.php
<?php
header("Access-Control-Allow-Origin:*");
header("Access-Control-Allow-Methods:GET,POST");
echo 111;die;
?>