首页 > 解决方案 > 代码可以在 XAMPP 服务器上运行,但不能在 000webhost.com 上运行

问题描述

function valform()
{
	var name = document.getElementById("username").value;
	var h2 = document.getElementById("height1").value;
	var w2 = document.getElementById("weight1").value;
	var r2 = document.getElementById("txtresult").value;
	
	if( name == ""  || h2 == "" || w2 == "" || r2 == "" )
	{
		alert("Please fill in the blank(s) first");
		return false;
	}
	if(!($('input[type=radio]:checked').size() == 12))
	{
		alert("You must answer all the questions");
		return false;
	}
}

因此,基本上上面的代码不能在 000webhost.com 中运行,但可以在 XAMPP 服务器上运行。如果我在未选中所有单选按钮时单击提交,它应该显示警报,但它只是转到另一个页面。我检查了所有语法是否正确,但仍然无法正常工作。所以我想知道为什么?链接:https ://cancertool123.000webhostapp.com/Questionnaire%20(Colon%20Cancer).php

一些解释会有所帮助。

标签: javascriptphphtmlxampp

解决方案


改变

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

正如您在控制台中看到的(在您的网站中按 F12),出现错误:

混合内容:“ https://cancertool123.000webhostapp.com/Questionnaire%20(Colon%20Cancer).php ”页面通过 HTTPS 加载,但请求了不安全的脚本“ http://ajax.googleapis.com/ajax ” /libs/jquery/1.11.1/jquery.min.js '。此请求已被阻止;内容必须通过 HTTPS 提供。

问题是您正在 https 站点中加载 http 文件。


推荐阅读