1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tests</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,500,700&display=swap" rel="stylesheet" /><link href="/fontawesome/fontawesome5121/css/all.css" rel="stylesheet" />
<style type="text/css">body {font-size:.9em;font-weight:400;font-family:'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif}</style>
</head>
<body>
<form method="post" action="./jajx-tests.html" id="form1" style="text-align:center">
<div id="produit_tarif_1" style="margin-top:20px">
<div style="padding-bottom: 20px;font-size: 2em;color: #177ab5;">webservice v1 - Essais</div>
<div><label id="t_label_1">Aucune donnée pour le moment</label></div>
<div id="dWait"><img src="/img/loader-006.gif" alt="Loading..." style="width:100px" /><br />
<span style="opacity:.2"><i class="fas fa-hourglass-half"></i> Tentative d'appel du webservice en cours...</span>
</div>
</div>
<div id="debug_ws" style="padding:20px;font-size:11px;color: #0ca5ff;display: inline-block;background-color: #ececec;margin-top: 20px;border-radius: 0;">
<label id="lbl_debug_ws"></label>
</div>
<script type='text/javascript'>
// Préparation des données à envoyer
var separ = String.fromCharCode(13) + String.fromCharCode(10); //"\r\n";
var formVars = '1' + separ;
formVars = formVars + '01' + separ;
formVars = formVars + '0000001' + separ;
formVars = formVars + 'REF00010000000000' + separ;
formVars = formVars + '1' + separ;
formVars = formVars + '001' + separ;
formVars = formVars + '01' + separ;
// Debug
console.log(formVars);
// Fonctions
function write_log(n) { $('#lbl_debug_ws').empty().append('<i class="fas fa-info-circle"></i> ' + n); }
function show_loader() { $("#dWait").css({ display: "block" }); }
function hide_loader() { $("#dWait").css({ display: "none" }); }
hide_loader();
// Début...
$(document).ready(function () {
$("#form1").ajaxStart(function () {
console.log("L'appel AJAX est lancé....");
write_log("L'appel AJAX est lancé....");
show_loader();
});
$("#form1").ajaxSuccess(function(){
console.log("L'appel AJAX a réussi !");
write_log("L'appel AJAX a réussi !");
hide_loader();
});
$("#form1").ajaxError(function () {
console.log("L'appel AJAX a échoué.");
write_log("L'appel AJAX a échoué. Consultez la console pour en savoir plus.");
hide_loader();
});
$.ajaxSetup({
async: true,
headers: {
'Accept': '*/*',
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'none'
}
});
$.ajax({
url: 'http://XXX.XXX.XXX.XXX:7002/APP_NAME_WS',
type: 'POST',
dataType: 'text',
data: formVars,
// crossDomain: true,
timeout: 5000,
cache: false,
withCredentials: false,
success : function(code_html, statut){
console.log('succès : ' + statut);
},
error : function(resultat, statut, erreur){
console.log('error : ' + erreur);
},
complete : function(resultat, statut){
console.log('Complete : ' + statut);
}
});
});
</script>
</form>
</body>
</html> |
Partager