I have a php script that is insert large result on my mysql dbb. I did jquery script to waiting the end of the php script. But I have a timeout error. Do you have an idea to change the timeout to let the script do his job ?
Thank you
Jquery script :
<script type="text/javascript">
var dataReturn='';
function makeRequest(url){
$('#preloader').show();
$.get(url, function(data) {
timeout: timeoutvalue
$('#resultDiv').html(data);
$('#preloader').hide();
}).fail(function() {
alert( 'Error occured during requesting the page' );
$('#preloader').hide();
});
}
function makePostRequest(url, params){
$('#preloader').show();
$.post(url,params, function(data){
$('#resultDiv').html(data);
$('#preloader').hide();
}).fail(function() {
alert( 'Error occured during requesting the page' );
$('#preloader').hide();
});
}
</script>
<style>
#preloader{
display:none;
}
</style>
Button to start de script :
<input type="submit" onClick="makeRequest(\'inserttodbb.php?fonction=import_csv\')" value="" style="width:59px; height:17px; background:url(images/button-importstart.png) repeat-x left center;border:0;margin-left:0px; float:center;" />
Php page inserttodbb.php :
if(isset($_GET['fonction']) and $_GET['fonction']=="import_csv_valid")
{
$data=$_SESSION['listeok'];
$count=count($data);
foreach($data as $numero)
{
$req=("INSERT INTO contact VALUES('".$idclient."','', '".$numero."','','','','','','','0')");
$doins = mysql_query($req) or die(mysql_error());
}
echo 'Import OK for '.$count.' number !';
}
I have not the problem of time out when I load the php page. But when I try to use the ajax loader I have a problem with the message "Error occured during requesting the page". I tryed to put the timeout to 900000 but the problem continue. An idea ?
function makeRequest(url){
$('#preloader').show();
$.ajax({
type: "GET",
url: url,
timeout: 9000000, //10 seconds, define this value in milliseconds
success: function(data){
$('#resultDiv').html(data);
$('#preloader').hide();
},
error: function() {
alert( 'Error occured during requesting the pagesssssss' );
$('#preloader').hide();
}
});
}