“Exemple AJAX PHP” Réponses codées

Comment appeler la fonction PHP à partir de l'ajax

$.ajax({ url: 'phpscriptname.php',
         data: {function2call: 'getEmployeesList', otherkey:otherdata},
         type: 'post',
         success: function(output) {
                      alert(output);
         }
});
Jolly Jackal

Exemple AJAX PHP

<p>Start typing a name in the input field below:</p>
<p>Suggestions: <span id="txtHint"></span></p>

<form>
First name: <input type="text" onkeyup="showHint(this.value)">
</form>

<script>
function showHint(str) {
  if (str.length == 0) {
    document.getElementById("txtHint").innerHTML = "";
    return;
  } else {
    const xmlhttp = new XMLHttpRequest();
    xmlhttp.onload = function() {
      document.getElementById("txtHint").innerHTML = this.responseText;
    }
  xmlhttp.open("GET", "gethint.php?q=" + str);
  xmlhttp.send();
  }
}
</script>
naly moslih

Réponses similaires à “Exemple AJAX PHP”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code