Advertisement
Guest User

Untitled

a guest
Jan 27th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     function send (){
  2.    
  3.     function player (name,club){
  4.     this.name = name,
  5.     this.club = club
  6.     }
  7.     var player1 = new player('aubamayang','arsenal');
  8.     var array = new Array();
  9.     array.push(player1);
  10.    
  11.     var jsonText = JSON.stringify(array);
  12.     var ajax = new XMLHttpRequest();
  13.     xhr.onreadystatechange = function (){
  14.         if (this.readyState == 4 && this.status == 200){
  15.                          }
  16.        
  17.     }
  18.     xhr.open("POST","http://localhost/quiz/test.php",true);
  19.     xhr.setRequestHeader("Content-Type", "application/json");
  20.    
  21.     xhr.send(jsonText);
  22.    
  23.     }
  24.  
  25. <?php
  26.     header("Content-Type: application/json");
  27.     $var = $_POST ;
  28.     json_decode($_POST);
  29.     echo ' <script>alert($var.length)</script>' ;
  30.     $host="127.0.0.1";
  31.     $user="root";
  32.     $password="";
  33.     $database="tasks";
  34.     echo 'connected';
  35.     //$connect = mysqli_connect($host,$user,$password,$database);
  36.     //$query = "insert into test (name,club)values('".$data['name']."','".$data['club']."')";
  37.     //mysqli_query($connect , $query);
  38.  
  39.    
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement