AJAX Object

0 favourites
  • 6 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Anyone know how to send POST / GET to a PHP file without using AJAX ?? I've given up using does not work because !!! Does not bring the return of PHP !!! Ja quit !!

    Thank you.

  • Hi

    What is your problem with the return ?

    AJAX is working fine for me, have been making a Login before, so can you specify your problem ? And show your code or Blocks in C2 ? ^^

  • Hi.

    I have the same problem, no response to show in Construct.

    Here are my PhP and my Blocks :

    <?php
    	$serveur = "127.0.0.1";
    	$db ="oze";
    	$user = "oze";
    	$mdp = "oze";
    	
    	$login = $_GET['oze_login'];
    	$passwd = md5($_GET['oze_passwd']);
    	
    	
    	//Connexion DB
    	$link = mysqli_connect($serveur, $user, $mdp, $db) or die("Erreur de connexion au serveur !" . mysqli_error($link));
    	
    	$qPseudoUnique = "SELECT Pseudo_Joueur, Mdp_Joueur FROM joueur WHERE Pseudo_Joueur = '$login';" or die("Erreur de requête !" . mysqli_error($link)); // Existence ou non d'un pseudo et tests de connexion
    	if ($resPseudo = mysqli_query($link, $qPseudoUnique)) {
    		if (mysqli_num_rows($resPseudo) != 0) { // Si la requête renvois un résultat
    			while ($row = mysqli_fetch_array($resPseudo)) {
    				$pseudoJoueur = $row["Pseudo_Joueur"]; // Attribution du pseudo et mot de passe à des variables
    				$mdpJoueur = $row["Mdp_Joueur"];
    			}
    			if (($pseudoJoueur == $login) && ($mdpJoueur == $passwd)){ // Si login et Mdp valides, connexion
    				echo "Connecté !";
    			}else { // Sinon message d'erreur
    				echo "Vérifiez votre mot de passe !";
    			}
    		}else { // Si pas de compter, inscription d'un nouveau joueur
    			$qNouveau = "INSERT INTO `oze`.`joueur` (`ID_Joueur`, `Pseudo_Joueur`, `Mdp_Joueur`) VALUES (NULL, '$login', '$passwd');" or die("Erreur de requête !" . mysqli_error($link));
    			if ($resultats = mysqli_query($link, $qNouveau)) {
    				echo "Inscription réussie !";
    			}else {
    				echo "Erreur lors de l'inscription !";
    			}
    		}
    	}
    	echo "Boulet !";
    	
    	mysqli_close($link);
    ?>[/code:12am6hg0]
    
    [img="http://i57.tinypic.com/3144b49.png"]
    
    Thank you for your help.
  • OK... Well.... I just find the answer...

    We must add :

    header('Access-Control-Allow-Origin: *');
    [/code:285qvmfn]
    
    Juste after <?php in our PhP file !
    It works fine for me.
  • Hi.

    I have the same problem, no response to show in Construct.

    Here are my PhP and my Blocks :

    Thank you for your help.

    Have you tried for debugging

    1. set tDebug1 to your request url to make sure tbPseudo.Text is correct and not empty

    2. Entered the request url in to a browser and does it display anything?

    Edit: Nevermind

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The most common reason it doesn't work is the cross-domain security restrictions in the browser. This is documented.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)