Answers for "how to get data from db using ajax"

0

how to get data from db using ajax

<script>
    $(function(){
        $(".like").click(function(){

            var postid = $(this).attr("id");
              $.ajax({
                type:'POST',
                url:'addlike.php',
                data:'id='+postid,
                success:function(data){
                   if(data=="you already liked this post"){
                       alert(data);
                     }
                   else{
                      $('a#'+postid).html(data);
                      }
                }
            });

        });
    });

</script>
Posted by: Guest on October-25-2021
0

how to fetch data from database in javascript using ajax

var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      return this.responseText;
    }
  };
  xhttp.open("GET", "[your database]", true);
  xhttp.send();


//add the url of your database in the [your database] string.
Posted by: Guest on April-15-2021

Code answers related to "how to get data from db using ajax"

Code answers related to "Javascript"

Browse Popular Code Answers by Language