5
I have the following situation...
- A purely javascript client application that runs with Node.js, where you post a JSON, as follows:
doLoad = function (livrosList){
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://servidor_remoto/webservice/webs.php", true);
xmlhttp.setRequestHeader("Content-Type", "application/json; charset=utf-8");
arqJson = JSON.stringify(livrosList);
xmlhttp.send(arqJson);
}
- A PHP Webservice that receives the free listList and stores your data in the Mysql database:
include('LivrosList.php');
header('Content-Type: application/json; charset=utf-8');
header("access-control-allow-origin: *");
$obj_php = json_decode(stripslashes($_POST['arqJson']));
if(empty($_POST['arqJson'])){
return;
}
$livros = new Livros;
foreach ( $obj_php as $liv ) {
$livros->insertLivros($liv->nome, $liv->numeropaginas);
}
The problem is that $_POST['arqJson'] is not being recognized. I see that in the apache log is occurring that arqJson is not defined. I don’t know about the fact that it’s on a remote server. So how could I send this data list to the webservice and store such data in the database? Thanks for your help!
Thank you very much, that was the problem. It worked!!
– Maiara Coelho