使用ajax / jquery从php获取变量

this code doesn't work for me ! i want to display the variable $nom in a notification using UIkit . here the php file (verif1.php) :

<?php



$IMEI = $_GET['IMEI'];
$region = $_GET['region'];
$numero = $_GET['numero'];
$nom = $_GET['nom_client'];

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";

/* <input type="hidden" id="nom" value="valeurDeMariable"> </input> */

try {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    // set the PDO error mode to exception
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $sql = "INSERT INTO client ( nom_client,IMEI,numero ) VALUES ('$nom',$IMEI,$numero)";
    // use exec() because no results are returned
    $conn->exec($sql);
    echo "New record created successfully pour "."$nom";
    echo json_encode(array('nom' => $nom ));
    }
catch(PDOException $e)
    {
    echo $sql . "<br>" . $e->getMessage();
    }

$conn = null;


?>

` AND HERE's the javascript code :

<script language="Javascript">
$.ajax({
    url: 'verif1.php',
    type: 'POST',

    dataType: 'json',
    data: {
        "varA": nom
    },

    cache: false,
    success: function(data) {
        alert('Items added');
    },
    error: function(e) {
        console.log(e.message);
    }
});
</script>
<script language="Javascript">
$(document).ready(function() {

    setTimeout(function() {
        ui.notify('Notification 01', 'Cette premiere notification s\'affichera quelques secondes puis disparaitra.')
            .effect('slide');

        setTimeout(function() {
            ui.notify('Notification 02', 'Cette deuxieme notification s\'affichera plus longtemps que la premiere.')
                .closable()
                .hide(8000)
                .effect('slide');


        }, 200);
    }, 200);


});
</script>

the problem is that $.ajax function doesn't show anything and i don't know how to know if it's working or not!! please help :)

First thing:

Replace all $_GET with $_POST

Because, you have chose post method in: type: 'POST',

$IMEI = $_GET['IMEI'];
$region = $_GET['region'];
$numero = $_GET['numero'];
$nom = $_GET['nom_client'];

To:

$IMEI = $_POST['IMEI'];
$region = $_POST['region'];
$numero = $_POST['numero'];
$nom = $_POST['nom_client'];

Also, from the code you have provided:

data: {"varA": nom},

Where is nom defined?

i have a form

<div id="content">
            <form method="get" action="verif1.php">
                <b><label for="IMEI">Veuillez entrer votre IMEI : </label></b>
                <input type="string" id="IMEI" name="IMEI"/><br /><br />
                &nbsp;&nbsp;<b><label for="nom_client">Veuillez entrer votre nom : </label></b>
                <input type="string" id="nom_client" name="nom_client"   /><br /><br />
                <b><label for="region">Veuillez entrer votre région : </label></b>
                <input type="string" id="region" name="region"   /><br /><br />
                <b><label for="numero">Veuillez entrer votre numéro : </label></b>
                <input type="string" id="numero" name="numero"   /><br /><br />

                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="submit" value="Enter" />
            </form>

        </div>

and from this form i go directly to verif1.php so idon't really know how to erase those $_GET