Accès refusé jquery.js Code 0
Bonjour,
Je réalise une application web pour ma société (serveur IIS / SQL Serveur / PHP).
Sur une page, j'appelle un script PHP dans un $.post. Quand je le teste en local, pas de problèmes.
Par contre, j'ai testé en me connectant à partir d'un autre PC sur mon serveur web (sur ma machine).
Quand j'appelle le fameux script il me met sous IE : accès refusé jquery.js Code 0 Ligne 127.
Sous FF, avec firebug, il me met comme erreur : data is null (où data est en fait mon retour du script PHP au format JSON).
Voici le code Javascript :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| $.post("http://"+IP_SERVEUR+"/SinistreAutomobile/page/afficherInformationsAgent.php",
{codeAgent:codeAgent.val()},
function callback(data){
if(data['codeRetour'] == '1'){
$("#nom").val(data['nom']);
$("#prenom").val(data['prenom']);
$("#datePermis").val(data['datePermis']);
$("#nomGarant").val(data['nom']+" "+data['prenom']);
}else{
$("#noAgent").append("<p>Code agent non reconnu ! Vérifiez le code entré ou remplissez les informations manuellement.</p>");
}
$("#afficherInfos").empty();
},
"json"); |
Et le code PHP :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| <?php
$codeAgent = $_POST["codeAgent"];
//echo $codeAgent;
include '../../Outils/BaseDeDonnees/connexion.php';
$sql = "SELECT COUNT(*) FROM agent WHERE code_agent = ".$codeAgent;
$infos = array();
if ($res = $conn->query($sql)) {
/* Récupère le nombre de lignes qui correspond à la requête SELECT */
if ($res->fetchColumn() > 0)
{
/* Effectue la vraie requête SELECT et travaille sur le résultat */
$sql = "SELECT * FROM agent WHERE code_agent = ".$codeAgent;
foreach ($conn->query($sql) as $data)
{
if($data["date_permis_conduire_agent"] != null){
$date_timestamp = strtotime($data["date_permis_conduire_agent"]);
$date_format = date("d/m/Y",$date_timestamp);
$infos = array(
'codeRetour' => '1',
'nom' => $data["nom_agent"],
'prenom' => $data["prenom_agent"],
'datePermis' => $date_format
);
}else{
$date_format = "";
$infos = array(
'codeRetour' => '1',
'nom' => $data["nom_agent"],
'prenom' => $data["prenom_agent"],
'datePermis' => $date_format
);
}
// print "Nom : " . $data['nom_agent'] . "\n";
}
}
/* Aucune ligne ne correspond */
else {
$infos = array(
'codeRetour' => '0');
//print "Aucune ligne ne correspond à la requête.";
}
}
echo json_encode($infos);
?> |
Merci d'avance pour vos réponses
Maxime