I have an ajax script who use jquery and look like that :
$('#myButton').click(function()
{
$.ajax({
url : "sqlScript.php",
type : 'POST',
data : '',
dataType : 'html',
beforeSend : function(newRequest,opts)
{
$('#myButton').attr("disabled", "disabled");
},
success : function(code_html, statut)
{
location.reload();
},
error : function(resultat, statut, erreur)
{
alert('error')
location.reload();
}
});
})
And in my sqlScript.php i have nothing like that :
require_once('bdd.php');
$req= $bdd->query("UPDATE ".$table1
." JOIN ".$table2
." ON ".$table1.".".$field1." = ".$table2.".".$field1
." AND ".$table1.".".$field2." = ".$table2.".".$field2
." SET ".$table2.".".$field3." = ".$table2.".".$field3
);
echo "OK";
And each time i click on the button with id 'myButton' the ajax launch the script but at the end of the script it don't pass in the success but in the error and i don't don't why. More weird : their is no error, i mean the script finish well and my UPDATE is completly done.
But this UPDATE is really long something like 10 minutes ... so peraphs it's because of that.
======== EDIT ========
In bdd.php i only have the define of my database :
$host = "localhost";
$db_name = "db";
$user = "root";
$password = "";
try
{
$bdd = new PDO('mysql:host='.$host.';dbname='.$db_name.';charset=latin1', $user, $password);
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
$table1 = 'table1';
$table2 = 'table2';
$field1 = 'field1';
$field2 = 'field2';
$field3 = 'field3';