connection failed to test-connessione.php
code b4j
TEST-CONNESSIONE.PHP
code b4j
B4X:
Dim we,wvjo As JavaObject
we.InitializeNewInstance("javafx.scene.web.WebEngine",Null)
wvjo = WebView1
we = wvjo.RunMethod("getEngine",Null)
Dim useragent As String=$"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36"$
we.RunMethod("setUserAgent",Array(useragent))
Dim s As StringBuilder
s.Initialize
s.Append($"
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#bottone").click(function(){
var nome = $("#nome").val();
var siteURL = "https://www.my-website.com/";
$.ajax({
type: "POST",
url: "test-connessione.php",
data: "nome=" + nome ,
dataType: "html",
success: function(msg)
{
$("#risultato").html(msg);
},
error: function()
{
$("#risultato").html(msg);
// alert("Chiamata fallita, si prega di riprovare...");
}
});
});
});
</script>
</head>
<body>
<form id="modulo" name="modulo">
<p>Nome</p>
<p><input type="text" name="nome" id="nome">
<input type="button" id="bottone" value="Invia i dati">
</form>
<div id="risultato"></div>
</body>
</html>
"$)
Dim startPage As String = s
WebView1.Loadhtml(startPage)
Sub WebView1_MouseClicked (EventData As MouseEvent)
Dim joWV As JavaObject = WebView1
Try
joWV.RunMethodJO("getEngine", Null).RunMethod("executeScript", _
Array As String("document.getElementById('modulo').click();"))
Catch
Log(LastException.Message)
End Try
End Sub
TEST-CONNESSIONE.PHP
B4X:
<?php
echo "Chiamata avvenuta correttamente";
?>