1
I’m trying to get php to send a response to the Avascript file with information, in which Avascript makes a request for php in ajax, and php sends a random amount of information, php will pull all records from the database and respond to ajax with this information, and finally Avascript will mount html, I at first thought of building html in php, but I saw that this is not a good option.
OBS: there are two PHP files one that will generate the database and the other that will receive the html by the ajax response.
My codes are just below.
javascrip
$.ajax({
url : "file.php",
type : "POST",
data : { alpha : null},
success : function(){console.log("work")},
error : function(){console.log("error")}
});
PHP
$q = "SELECT * FROM `table`";
$r = $conn->query($q);
while ($row = $r->fetch_assoc()) {
}
echo json_encode($var); //Var || array || objeto
My question, how do I send this information back to Java?
All that you flaunt with PHP, being by
echo
,print
, or any other means, will be defined as the body of the HTTP response returned to the client (in this case, the JS).– Woss
I forgot to write that they are two distinct files, it was bad =/
– WEB Last Wolf
As well as two distinct files?
– Woss
There are three files, two PHP and a JS, one is the Index.php that will receive the post code $("#id"). html("RESP") and the other PHP that will generate the database.
– WEB Last Wolf