0
<html>
<head>
<title> chk </title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
function enviar() {
var lista = $("#lista_id").val();
var linhaenviar = lista.split("\n");
var index = 0;
linhaenviar.forEach(function(value) {
setTimeout(
function() {
$.ajax({
url: 'config.php',
type: 'POST',
async: false,
dataType: 'html',
data: "lista=" + value,
success: function(resultado) {
$('#oi').html($('#oi').html() + resultado + "<br>");
}
})
}, 10 * index);
index = index + 1;
})
}
</script>
</head>
<body>
<center>
<textarea name="lista" id="lista_id" rows="10" cols="40">
</textarea>
<br>
<input type="button" value="testar" onclick="enviar();"></input>
<br>
<div id="live" name="live">
<p></p>
</div>
<div id="Die" name="Die">
<p></p>
</div>
</center>
</body>
</html>
//PHP SEPARADO NO CONFIG.PHP
<?php
$checker = $_POST["lista"];
$ip = explode("|", $lista)[0];
$porta = explode("|", $lista)[1];
function GetStr($string, $start, $end){
$str = explode($start, $string);
$str = explode($end, $str[1]);
return $str[0];
}
$login = ''.$ip.' | '.$porta.'';
$ch = curl_init();
$url = "local da requisição";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "_proxy=$ip&_port=$porta");
$resultado = curl_exec($ch);
curl_close($ch);
$name = $resultado;
$valor = GetStr($name, 'Sair',";");
if ( $valor == "Sair" ) {
echo '<script>$(document).ready(function(){$("#Live").prepend("'.$login.' <br>")});</script>' ;
} else {
echo '<script>$(document).ready(function(){$("#Die").prepend("'.$login.' <br>")});</script>' ;
}
?>
How do I display my PHP results in a div
? Follow my code, I wish each result to be displayed in your div
.
if ( $valor = "Sair" ) {
echo '<script>$("#funcionou").prepend("'.$logout.' <br>");</script>' ;
} else {
echo '<script>$("#naofuncionou").prepend("'.$logout.' <br>");</script>' ;
}
<div id="funcionou" name="Lives">
</div>
<div id="naofuncionou" name="Dies">
</div>
Wouldn’t it be easier for you to call
echo
with the desired message within thediv
where you want to display it?– Woss
And that structure wouldn’t even work, because the Divs weren’t loaded when the scripts were called.
– Sam