【问题标题】:Code can run in XAMPP server but cannot run in 000webhost.com代码可以在 XAMPP 服务器上运行,但不能在 000webhost.com 上运行
【发布时间】:2018-06-13 05:10:52
【问题描述】:

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

一些解释会有所帮助。

【问题讨论】:

标签: javascript php html xampp


【解决方案1】:

改变

<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 文件。

【讨论】:

  • 非常感谢先生!你拯救了我的一天。 :)
【解决方案2】:

您正在从 http 加载 jquery 文件,并且您的网站在 https 上运行,因此将其更改为此

https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js

会有用的

【讨论】:

  • 感谢!这就是为什么它不能工作大声笑。无论如何,非常感谢你;)
猜你喜欢
  • 1970-01-01
  • 2018-03-01
  • 2019-03-07
  • 2023-04-04
  • 1970-01-01
  • 2020-11-01
  • 2014-07-14
  • 2012-07-24
  • 1970-01-01
相关资源
最近更新 更多