Advertisement
Guest User

Untitled

a guest
Dec 27th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. function req( request, user, password, carriera, callback){
  2.  
  3. var url = "http://esse3unica.azurewebsites.net/index.php";
  4.  
  5.  
  6.  
  7. var params = "request=" + request +"&user=" + user +"&password=" + password +"&carriera=" + carriera;
  8.  
  9.  
  10.  
  11. var http = new XMLHttpRequest();
  12.  
  13.  
  14.  
  15. http.open("POST", url, true);
  16.  
  17.  
  18.  
  19. //Send the proper header information along with the request
  20.  
  21. http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  22.  
  23.  
  24.  
  25. http.onreadystatechange = function() {//Call a function when the state changes.
  26.  
  27. if(http.readyState == 4 && http.status == 200) {
  28.  
  29. callback(JSON.parse(http.response));
  30.  
  31. //alert(http.responseText);
  32.  
  33. }
  34.  
  35. }
  36.  
  37. http.send(params);
  38.  
  39. } //req
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement