javascript - 代码可以在 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
一些解释会有所帮助。
解决方案
改变
<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 文件。
推荐阅读
- python - 在 Python Pandas 中,如何在不使用 for 循环的情况下比较一个数据帧中的不同行
- python - 'list' 对象没有属性 'short_name'
- python - 如何在 PyCharm 中进行 Pandas 造型?
- pyspark - 流聚合未写入接收器
- python - Python中的多个数组输入
- wpf - 在 WPF 中使用 DrawingImage 作为按钮内容
- objective-c - 从 typedef 枚举转换为 NS_ENUM 会导致符号重复
- spring-boot - 如何在 Spring Boot 的预处理程序中获取 Request body{object}?
- ios - Ionic 4 应用程序在 iOs 13 上请求蓝牙权限
- keycloak - 无法在独立模式下启动 keycloak 服务器