UPDATE
Objective post data (age and name) from www.domain1.com
to www.domain2.com/try.php
Problem am getting this on domain2.com/try.php
Undefined index: name
Undefined index: age
Index.html on domain1
<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
<?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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.