External PHP - to - Agent communication

I need to start from PHP page (my “external” website),
call my agent code (hidden url)
then post a message (x=1) but the document.url & location.reload() is still my external website
Is there a sort of cross-site restriction ?
I am not able to read any post message from the PHP

What have I missed ?

Entry Page PHP
`

<?php header('Access-Control-Allow-Origin: *'); $url = 'http://agent.electricimp.com/xxxxxxxxxxx'; $fields = $_POST; foreach($fields as $key=>$value) { if ($key !='code') { $fields_string .= $key.'='.$value.'&'; }} $fs = rtrim($fields_string,'&'); echo $fields; echo $url; echo $fs; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS,$fs); curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); $result = curl_exec($ch); curl_close($ch); ?>

`

Agent Code
`
function loadPage(res) {
local html = “"
+“SEND”
+""
res.send(200, html);
}

http.onrequest(function(request,res) {
server.log("Request: " + request.body);
local data = http.urldecode(request.body);
if (request.body == “”) { loadPage(res); }
else if (“x” in data) { ; loadPage(res); }
});
`

THANK YOU