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 :)