[英]Send and collection of data from one server to another
UPDATE更新
Objective post data (age and name) from www.domain1.com
to www.domain2.com/try.php
从www.domain1.com
到www.domain2.com/try.php
客观发布数据(年龄和姓名)
Problem am getting this on domain2.com/try.php
问题是在domain2.com/try.php
上得到这个
Undefined index: name未定义索引:名称
Undefined index: age未定义索引:年龄
Index.html on domain1域 1 上的 Index.html
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function () {
$("#clickMe").click(function () {
$.ajax({
type: 'post',
contentType: "application/json; charset=utf-8",
url: 'www.domain2.com/try.php',
dataType: "json",
data: {
name: "tom",
age: "30"
},
complete:
function (data) {
window.location = "www.domain2.com/try.php";
}
})
})
})
</script>
</head>
<body>
<input id="clickMe" type="button" value="clickme123"/>
</body>
</html>
try.php on domain2域2上的try.php
<?php
$name = $_POST['name'];
$age = $_POST['age'];
echo 'name:'.$name;
echo 'age:'.$age;
On the first domain just use a form and post to the second domain:在第一个域上,只需使用表单并发布到第二个域:
<html>
<head>
</head>
<body>
<form action="http://two.example.com/foo.php" method="POST">
<input type="hidden" name="name" value="tom">
<input type="hidden" name="age" value="30">
<input type="submit" value="Go">
</form>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.