<template>
<button type="submit" onclick="getPost" class="btn btn-default" id="register-form" style="margin-left: 35%; background-color: #008000; color: black; width: 30%;">Submit</button>
<iron-ajax
id="ajax"
method="POST"
body='[{"id": "1"}]'
url ="http://localhost/api/post.php"
on-response="success"
lastError="error"
debounce-duration="3000">
</iron-ajax>
</template>
<script>
Polymer({
is: 'register-form',
getPost:function(){
this.$.ajax.generateRequest();
},
success:function(r){
alert(r.detail.response);
},
error:function(r){
alert(r.detail.response);
}
});
</script>
Enter code here...
<?php
header('Access-Control-Allow-Origin: *');
if ($_POST){
echo $_POST['id'];
}
?>