Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function send (){
- function player (name,club){
- this.name = name,
- this.club = club
- }
- var player1 = new player('aubamayang','arsenal');
- var array = new Array();
- array.push(player1);
- var jsonText = JSON.stringify(array);
- var ajax = new XMLHttpRequest();
- xhr.onreadystatechange = function (){
- if (this.readyState == 4 && this.status == 200){
- }
- }
- xhr.open("POST","http://localhost/quiz/test.php",true);
- xhr.setRequestHeader("Content-Type", "application/json");
- xhr.send(jsonText);
- }
- <?php
- header("Content-Type: application/json");
- $var = $_POST ;
- json_decode($_POST);
- echo ' <script>alert($var.length)</script>' ;
- $host="127.0.0.1";
- $user="root";
- $password="";
- $database="tasks";
- echo 'connected';
- //$connect = mysqli_connect($host,$user,$password,$database);
- //$query = "insert into test (name,club)values('".$data['name']."','".$data['club']."')";
- //mysqli_query($connect , $query);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement