错误:无法加载ajax javascript文件。也许URL不正确?
生成用户报告时出现以下错误 错误:无法加载ajax javascript文件。也许是网址 不正确吗 URL:site.com/js/xajax.js 在控制台中,我看到以下消息: GetReport函数:错误:无法加载ajax javascript文件。也许URL不正确?,javascript,codeigniter,Javascript,Codeigniter,生成用户报告时出现以下错误 错误:无法加载ajax javascript文件。也许是网址 不正确吗 URL:site.com/js/xajax.js 在控制台中,我看到以下消息: GetReport函数: public function getReport() { $xajaxResponse = new xajaxResponse(); $this->template->assign("report", true); $user =& User:
public function getReport() {
$xajaxResponse = new xajaxResponse();
$this->template->assign("report", true);
$user =& User::getInstance();
//$this->template->assign("calendarMode", "noactive");
if ($user) {
$today = date("Y-m-d H:i:s");
//$doctor = $user->getDoctor();
//$doctorSettings = $doctor->getDoctorSettings();
//if ($doctorSettings->getTestTour() == 2) $this->template->assign("showAA", true);
if ($user->getSubscriptionDueDate() < $today) {
$this->template->assign("notlogin", true);
//$this->template->assign("doctor", $doctor);
}
}
// $user = User::getInstance();
// exit('here');
$doctor = $user->getDoctor();
$userState = $user->getState();
$doctorSettings = $doctor->getDoctorSettings();
if ($doctorSettings->getQuizType(1)) $this->template->assign('showBasic',1);
$states = $doctor->getStateArray();
$stateShow = false;
foreach ($states as $state) {
if ($state == $userState) {
$stateShow = true;
break;
}
}
$this->template->assign("user", $user);
$this->template->assign("doctor", $doctor);
$this->template->assign("stateShow", $stateShow);
$this->template->assign("date",$_SESSION["date"]);
if (file_exists("flash/{$user->getId()}/{$_SESSION["date"]}/paramArray")){
$lastReportParams = Patient::getReportParams($user->getId(),$_SESSION["date"]);
$allow = $lastReportParams["allow"][(NA_SITE?NA:WLA)];
}
else $allow = ($doctor->getShowGraph()==2)?in_array($user->getState(),$doctor->getShowGraphStatesCode()):$doctor->getShowGraph();
$this->template->assign("allow", $allow);
//allow user to view the report or not
$date = $_SESSION['thedate'];
if (file_exists("flash/{$user->getId()}/{$date}/allow")){
//$this->template->assign("date", $_SESSION['date']);
$this->template->assign("allow", true);
}
$content = $this->renderTemplate("patient/test_result.tpl");
$xajaxResponse->addAssign("cont", "innerHTML", $content);
$xajaxResponse->addAssign("loader", "style.display", "none");
$exJS = HttpSession::get("exJS");
$errors = HttpSession::get("errors");
if ($errors)
$xajaxResponse->script("document.getElementById('pr_rep_ref').style.display = 'none';
document.getElementById('pr_rep').style.display = 'none';");
$xajaxResponse->script(HttpSession::get("exJS"));
// $xajaxResponse->addScriptCall("createFlash", "");
return $xajaxResponse->getXML();
}
公共函数getReport(){
$xajaxResponse=新的xajaxResponse();
$this->template->assign(“报告”,true);
$user=&user::getInstance();
//$this->template->assign(“日历模式”,“无活动”);
如果($user){
$today=日期(“Y-m-d H:i:s”);
//$doctor=$user->getDoctor();
//$doctorSettings=$doctor->getDoctorSettings();
//如果($doctorSettings->getTestTour()==2)$this->template->assign(“showAA”,true);
如果($user->getSubscriptionDueDate()<$today){
$this->template->assign(“notlogin”,true);
//$this->template->assign(“医生”,$doctor);
}
}
//$user=user::getInstance();
//退出(“此处”);
$doctor=$user->getDoctor();
$userState=$user->getState();
$doctorSettings=$doctor->getDoctorSettings();
如果($doctorSettings->getQuizType(1))$this->template->assign('showBasic',1);
$states=$doctor->getStateArray();
$stateShow=false;
foreach($states作为$state){
如果($state==$userState){
$stateShow=true;
打破
}
}
$this->template->assign(“用户”,$user);
$this->template->assign(“医生”,$doctor);
$this->template->assign(“stateShow”,$stateShow);
$this->template->assign(“日期”,“会话[“日期]);
如果(文件\存在(“flash/{$user->getId()}/{$\会话[“日期”]}/paramArray”)){
$lastReportParams=Patient::getReportParams($user->getId(),$\u会话[“日期]);
$allow=$lastReportParams[“allow”][(NA_站点?NA:WLA)];
}
else$allow=($doctor->getShowGraph()==2)?在数组中($user->getState(),$doctor->getShowGraphStatesCode()):$doctor->getShowGraph();
$this->template->assign(“允许”、$allow);
//是否允许用户查看报告
$date=$\会话['thedate'];
如果(文件_存在(“flash/{$user->getId()}/{$date}/allow”)){
//$this->template->assign(“日期”,“会话['date']);
$this->template->assign(“允许”,true);
}
$content=$this->renderTemplate(“patient/test_result.tpl”);
$xajaxResponse->addAssign(“cont”,“innerHTML”,“$content”);
$xajaxResponse->addAssign(“加载器”、“样式显示”、“无”);
$exJS=HttpSession::get(“exJS”);
$errors=HttpSession::get(“errors”);
如果($errors)
$xajaxResponse->script(“document.getElementById('pr_rep_ref')。style.display='none';
document.getElementById('pr_rep').style.display='none';');
$xajaxResponse->script(HttpSession::get(“exJS”);
//$xajaxResponse->addScriptCall(“createFlash”,即“”);
返回$xajaxResponse->getXML();
}
xajax脚本正在通过HTTP而不是HTTPS加载
Chrome现在会阻止脚本,因为您正在HTTPS环境中运行
您可以通过在htaccess中设置hsts头来修复此临时问题
.htaccess
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
Header set Content-Security-Policy "upgrade-insecure-requests"
RewriteCond %{HTTPS} !=on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301]
更多信息:通过向htaccess添加上述行,现在它抛出500个internel服务器错误。您是否使用apache、nginx或其他东西作为Web服务器?apache/2.2.15(CentOS)我更改了代码片段,请重试。如果它不起作用,您应该找到通过HTTP加载的脚本
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
Header set Content-Security-Policy "upgrade-insecure-requests"
RewriteCond %{HTTPS} !=on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301]