Search
 
SCRIPT & CODE EXAMPLE
 

PHP

complete ajax request jquery php call | ajax request

<script type="text/javascript">
    function ajaxCall(formID, showID) {
        var form = $('#' + formID);
        $.ajax({
            type: form.attr('method'),
            url: form.attr('action'),
            data: form.serialize(),
            dataType: "JSON",
            cache: false,
            success: function (data, status, xhr) {
                $('#' + showID).html('').fadeOut('fast');
                $('#' + showID).html(data).fadeIn('slow');
            },
            error: function (xhr, status, error) {
                //alert(xhr);
                console.error(xhr);
            }
        });
    }
</script>
Comment

AJAX PHP Example

<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>
Comment

PREVIOUS NEXT
Code Example
Php :: german locale php 
Php :: laravel response json status 500 
Php :: como destruir uma variavel de sessão 
Php :: laravel file store 
Php :: php domdocument list all elements 
Php :: laravel get route parameters in blade 
Php :: laravel middleware in constructor 
Php :: ternaire echo isset php 
Php :: php clear post data 
Php :: route codeigniter 
Php :: laravel undefined index 
Php :: Uncaught ReferenceError: commonL10n is not defined 
Php :: last item coma replace and php 
Php :: php stop loading page 
Php :: laravel blade @auth 
Php :: Session/Session.php error codeigniter 3 
Php :: Creating Laravel and Vue Project 
Php :: laravel chunk 
Php :: get_adjacent_post wordpress 
Php :: tinker faker 
Php :: run laravel seeder 
Php :: php socket connect 
Php :: get admin url wordpress 
Php :: laravel validation required if 
Php :: php pdo error 500 
Php :: Prevent direct url access to php file 
Php :: php check if user exists in database 
Php :: laravel seeder 
Php :: laravel copy image with new name 
Php :: laravel import csv to database 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =