2
I have the code below that runs on any PC and asks for information for a PHP file on a remote server.
How do I pass a parameter to this PHP using my JSON code?
So I can send a data and have a processed return.
I know it sounds simple, but I could only run in this scenario (HTML anywhere) and PHP (remote server) with this code. All other methods need to have all files on the server.
HTML + JS file (Runs on any computer running)
<script type="text/javascript">
var urlTeste = 'http://www.meuservidor.com/servidor.php?jsoncallback=?';
$(document).ready(function() {
//Mensagem enquanto não carrega a pagina
$('#resultado').html('Carregando...');
$.getJSON(urlTeste,null, function(data){
$('#resultado').html(data);
});
});
</script>
PHP file (on www.meuservidor.com/server.php server)
<?php
$var = date("d/m/Y H:i:s ");
echo $_GET["jsoncallback"] . '(' . json_encode($var) . ');';
?>
Thank you
And thank you for following my recommendation in the other question :)
– bfavaretto
In short, the call basically has to look like this: $.getJSON("url.php", {key: "value", other: "other value"}, Function(date)? $('#result').html(date); }); the code posted by @bfavaretto is very correct, I always use the call in this way in my projects. Abs
– Amauri
It really worked properly. Show! Thank you so much for your help.
– user3771516