jquery - Ajax request cause following : Failed to load resource: the server responded with a status of 500 (Internal Server Error) -
i know there lot of related article on , had tried of suggestions other sharing. here partial listing of code
$(document).ready(function() { $("#cron").click(function(event) { $('.update-body').html('<br />performing updates...<br />') event.preventdefault(); event.stoppropagation(); var request = $.ajax({ url: 'http://xx.xx.xx.xx/update/longprocessing', type: "get", contenttype: "application/json", beforesend: function (xhr) { var token = $('meta[name="csrf_token"]').attr('content'); if (token) { return xhr.setrequestheader('x-csrf-token', token); } }, datatype: "json" }); request.done(function(status) { var msg = ""; if(status.msg == '1') { msg = '<div class="alert alert-success">successfully updated.</div>'; } else if(status.msg == '2') { msg = '<div class="alert alert-info">no updates</div>'; } $('.update-body').html(msg); }); request.fail(function(jqxhr, textstatus) { var acc = [] $.each(jqxhr, function(index, value) { acc.push(index + ': ' + value); }); $('.update-body').html('<div class="alert alert-danger">' json.stringify(acc) + '</div>'); }); }); });
processing.php expected takes average of 40 minute complete. here problem, code runs , success message returned when run xampp on windows 10 platform.
when move code linux under xampp, processing.php shows no error , runs fine (so nothing wrong php code) when monitor network performance, when waiting (ttfb) time first byte hit 15 minutes, following error message : failed load resource: server responded status of 500 (internal server error) generated somewhere in jquery ajax code. using jquery1.12.3.
any appreciated.
i realize sometimes, php function called first time , after 6 minute, called second time followed 503 service not available. not happen in xampp under windows happens in linux. using laravel 5.2 framework follows:
route::get('/update/longprocessing', ['as' => 'updateprocess', 'uses' => 'project\processjobs@updateprocess']);
in processjobs.php, code follows:
public function updateprocess () { log::debug("update process started"); $counter =0; //get path linux folder ... //loop through folder 35000 csvfiles foreach (xxx xxx) { //for each file, read content, process , write single common csv files. $counter++; log::debug("counter value : " . $counter); } return response()->json(['msg'=>'1']); }
log file shows following:
update process started counter value : 1 counter value : 2 counter value : 3 ... ... counter value : 10000 update process started <--- second time called counter value : 10001 <--- counter still continue previous. counter value : 10002 <--- log file stop here , server return 503 service unavailable error.
Comments
Post a Comment