Answers for "get data using ajax jquery"

7

jquery ajax get

$.ajax({
    	url: "www.site.com/page",
    	success: function(data){ 
    	    $('#data').text(data);
    	},
    	error: function(){
    		alert("There was an error.");
    	}
    });
Posted by: Guest on March-28-2020
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
2

ajax get js

let xhr = new XMLHttpRequest();

xhr.open("GET", "une/url");

xhr.responseType = "json";

xhr.send();

xhr.onload = function(){
    if (xhr.status != 200){ 
        alert("Erreur " + xhr.status + " : " + xhr.statusText);
    }else{ 
        alert(xhr.response.length + " octets  téléchargés\n" + JSON.stringify(xhr.response));
    }
};

xhr.onerror = function(){
    alert("La requête a échoué");
};

xhr.onprogress = function(event){
    if (event.lengthComputable){
        alert(event.loaded + " octets reçus sur un total de " + event.total);
    }
};
Posted by: Guest on April-14-2021

Code answers related to "get data using ajax jquery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language