Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Chiamata ajax
  2. function reqImg( request, user, password, index, callback){
  3.     var url = "URL_IMAGE_API";
  4.  
  5.     var params = "request=" + request +"&user=" + user +"&password=" + password +"&carriera=" + carriera;
  6.  
  7.     var http = new XMLHttpRequest();
  8.  
  9.     http.open("POST", url, true);
  10.  
  11.     //Send the proper header information along with the request
  12.     http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  13.    
  14.     http.onreadystatechange = function() {//Call a function when the state changes.
  15.     if(http.readyState == 4 && http.status == 200) {
  16.         callback(http.response);
  17.         }
  18.     }
  19.     http.send(params);
  20. }
  21.  
  22. ////// QUI LO SNIPPET CHE USO PER PRINTARLA
  23. reqImg("imgProfilo", "user", "pass", "0", function( response ) {
  24.     //$('#imgProfilo').append(response); // non funziona
  25.     $('#imgProfilo').append('<img src="data:image/png;base64,' + response + '" />');
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement