Javascript 500从ajax请求(jQuery)到代码点火器控制器的错误
我想知道是否有人遇到过这个问题 我正在调用一个CI控制器,该控制器运行一个模型(在服务器上),对于特定场景需要更长的时间(大约5分钟)。问题是,在一个长请求之后,我得到了一个500错误,但当请求较短时(大约1.5分钟),我没有得到任何错误 一些我已经检查过的东西:Javascript 500从ajax请求(jQuery)到代码点火器控制器的错误,javascript,php,jquery,ajax,codeigniter-2,Javascript,Php,Jquery,Ajax,Codeigniter 2,我想知道是否有人遇到过这个问题 我正在调用一个CI控制器,该控制器运行一个模型(在服务器上),对于特定场景需要更长的时间(大约5分钟)。问题是,在一个长请求之后,我得到了一个500错误,但当请求较短时(大约1.5分钟),我没有得到任何错误 一些我已经检查过的东西: CI的“csrf_保护”已关闭 我在ajax调用中设置了一个长超时(900000) 我已经将PHP中的max_execution_time设置为900 我已将IIS中的空闲时间设置为(20分钟) 以下是我的ajax调用: $.aj
- CI的“csrf_保护”已关闭
- 我在ajax调用中设置了一个长超时(900000)
- 我已经将PHP中的max_execution_time设置为900
- 我已将IIS中的空闲时间设置为(20分钟)
$.ajax({
type:'POST',
url:"run/runScenario/" + saveOrUpdate + "/" + scenarioname + "/" + units + "/" + stateid + "/" + climatestationid + "/" + soiltexture + "/" +
moisturecontent + "/" + modsoilflag + "/" + slopelength + "/" + slopeshape + "/" + slopesteepness + "/" + vegcommunity + "/" +
basalcover + "/" + canopycover + "/" + rockcover + "/" + littercover + "/" + cryptogamscover,
data: {scenarioDescription: scenariodescription},
timeout:900000,
statusCode: {
500: function() {
alert( "page not found" );
}
},
success: function(runData){
$('#progressBar').append('<p>Done running scenario.</p>');
$('#progressBar').append('<p>Saving scenario...</p>');
saveScenarioResultsTable();
$('#progressBar').append('<p>Creating output table...</p>');
printScenarioResultsTable(scenarioname);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.responseText);
// stop timer
var end = new Date().getTime();
var execution_time = end - TIMER;
runTimeMessage = "<br/><b>Ran scenario in " + (parseInt(execution_time) * 0.001) + " seconds.</b>";
alert(runTimeMessage);
}
});
$.ajax({
类型:'POST',
url:“运行/运行场景/”+saveOrUpdate+“/”+scenarioname+“/”+units+“/”+stateid+“/”+climatestationid+“/”+soiltexture+“/”+
水分含量+“/”+modsoilflag+“/”+slopelength+“/”+slopeshape+“/”+slopesteepness+“/”+vegcommunity+“/”+
基底覆盖层+“/”+树冠覆盖层+“/”+岩石覆盖层+“/”+垃圾覆盖层+“/”+隐花覆盖层,
数据:{scenarioDescription:scenarioDescription},
超时:900000,
状态代码:{
500:函数(){
警报(“未找到页面”);
}
},
成功:函数(runData){
$(“#progressBar”).append(“Done running scenario.”);
$(“#progressBar”).append(“保存场景…”);
saveScenarioResultsTable();
$(“#progressBar”).append(“创建输出表…”);
printScenarioResultsTable(scenarioname);
},
错误:函数(xhr、ajaxOptions、thrownError){
警报(xhr.responseText);
//停止计时器
var end=new Date().getTime();
var执行时间=结束计时器;
runTimeMessage=“
在“+(parseInt(执行时间)*0.001)+”秒内运行场景。”;
警报(运行时消息);
}
});
更新我创建了一个测试函数(作为运行控制器的一部分),并在函数内设置了睡眠(300)。我也犯了同样的错误。但是,当我切换到sleep(299)时,函数成功运行。显然,每个请求有5分钟的限制。
我已经在php.ini中更改了*max_execution_time*。还有其他建议吗
更新#2我找到了解决问题的方法。问题是,因为在我的PHP设置中没有启用“安全模式”,所以在CodeIgniter.PHP中PHP超时被覆盖(第107行)。我正在运行CodeIgniter 2.1.4。我希望这对其他人有帮助。:) 只是一个想法,但不是对代码的修正: 如果您将使用两个不同的ajax请求,该怎么办
-------------------------------------------------------------------
Step Local server processing
-------------------------------------------------------------------
1. Request for processing >>> Server >>> Thread for processing
2. Descriptor of resource <<< Server >>> Descriptor of resource
3. Server <<< Result of processing
4. Request by descriptor >>> Server
5. Result <<< Server >>> Deletion of file or record
-------------------------------------------------------------------
-------------------------------------------------------------------
单步本地服务器处理
-------------------------------------------------------------------
1.处理请求>>>服务器>>>处理线程
2.资源描述符>资源描述符
3.服务器>服务器
5.结果>删除文件或记录
-------------------------------------------------------------------
那里:1,2-阿贾克斯#1,按需开火。
4,5-Ajax#2每10秒触发一次。stackoverflow不使用bbcode标记。请查看页面有趣的是,如果您将鼠标悬停在代码图标上方,我会看到“
”建议。请在浏览器中手动键入您的服务脚本以及所有必需的参数,以查看您是否真的收到错误500-如果是-服务端上的问题不在附加的代码中-其他更新。我的CI 2.1.3安装仍存在此问题。在CI 1.7.2下运行时,我不会出现这种行为。我想,问题可能出在CI 2.1.3会话类上。