这个网站工作正常,但突然出现了错误.
意外的令牌( - 这意味着什么?看起来对我来说是正确的,并且已经好几个月了.
<script>
function (){ <--"Uncaught SyntaxError: Unexpected token (" here
$(".message").focus(function() {
$("#bubble").fadeOut();
}).blur(function() {
$("#bubble").fadeIn();
});
})();
</script>
Run Code Online (Sandbox Code Playgroud) 它在JSFiddle中工作,但在我的代码中,innerHTML调用将无法工作,因为它似乎无法找到指定的ID.但我可以在页面上清楚地看到它.
该代码用于倒数计时器.这是代码:
<script>
// set the date we're counting down to
var target_date = new Date("Aug 15, 2019").getTime();
// variables for time units
var days, hours, minutes, seconds;
// get tag element
var countdownOpening = document.getElementById("countdownOpening");
// update the tag with id "countdownOpening" every 1 second
setInterval(function () {
// find the amount of "seconds" between now and target
var current_date = new Date().getTime();
var seconds_left = (target_date - current_date) / 1000;
// do some time calculations
days = parseInt(seconds_left …Run Code Online (Sandbox Code Playgroud) 我无法理解为什么这种情况会持续下去.
我有一些存储在数组中的单词:
$poolOne=array("sparkly","sporty","happy","confident","awesome","funny","awkward","mad","silly","dynamic",
"handsome","merry","horrid","funky","loud","chirpy","posh","clever","pretty","athletic");
Run Code Online (Sandbox Code Playgroud)
对此数组的调用会选择四个随机字并将其输出到a中 <span>
<?php foreach (array_rand($poolOne, 4) as $key) {
echo "<span>".$poolOne[$key]."</span>";
}?>
Run Code Online (Sandbox Code Playgroud)
为了生成一个新的随机四个单词集而不刷新页面,我使用了一个非常简单的AJAX调用,只重新加载该部分,并为您提供一组新的四个单词.
你可以在这里看到这个,页面加载div中的代码wordbank,然后当运行AJAX(onClick绿色按钮)时,它再次从一个名为的文件加载相同的PHPwordbank.php
http://francesca-designed.me/create-a-status/index.php
这是标准的AJAX调用,没什么特别之处:
function refreshWords()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("wordbank").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","wordbank.php",true);
xmlhttp.send();
}
Run Code Online (Sandbox Code Playgroud)
这一切都很好,你可以在上面的链接上看到.
但是下一步,我想使用jQuery UI来实现拖放的单词.这一步的第一步是将spans我的每个单词都放在一个类中,draggable这样jQuery可以做到这一点.但这是我遇到问题的地方.
一旦我添加class="draggable"到PHP调用,整个事情就会中断.
为什么只是简单地为这个调用添加一个类名呢?
这里没有
echo …Run Code Online (Sandbox Code Playgroud) 这是我的按钮示例:
<button id="question_1a" disabled">Next question</button>
Run Code Online (Sandbox Code Playgroud)
我想将按钮的样式设置为标准样式,background-color如果禁用它们则不同:
input[type=button][disabled]{
background-color:#CCC;
}
input[type=button]{
background-color: #6CB300;
color:#fff;
border:0;
font-size:1.5em;
padding:2% 3%;
}
Run Code Online (Sandbox Code Playgroud)
这似乎不正确,如何选择禁用按钮和正常按钮?
file_put_contents会添加0而不是传递给它的字符串是什么原因?
它为每次尝试提交文件添加0.所以000第三次尝试.
$masterpostEntry = $title . "~" . $filetitle;
$file = "../posts/master-allposts.txt";
$current = file_get_contents($file);
$current .= $masterpostEntry + "\n";
file_put_contents($file, $current);
Run Code Online (Sandbox Code Playgroud)
$ masterpostEntry的回显显示正确的结果:
CSS-Only Solution For UI Tracking~css-only-solution-for-ui-tracking
Run Code Online (Sandbox Code Playgroud)
但是master-allposts.txt的内容是:
000
Run Code Online (Sandbox Code Playgroud) 我使用的是 HTML5 日期格式,我想用当前日期自动填充它,但允许对其进行更改。
以前使用一个简单的文本框,我可以使用 PHP 来恢复表单上的当前日期,但仍然可以对其进行编辑,如下所示:
<input type="text" value="<?php echo date('d / m / Y'); ?>"/>
Run Code Online (Sandbox Code Playgroud)
但是当date用作输入类型时,PHP 值会被覆盖并替换为dd/mm/yyyy。
<input type="date" value="<?php echo date('d / m / Y'); ?>"/>
Run Code Online (Sandbox Code Playgroud)
任何想法如何使用 HTML5 新输入类型但仍然能够提供默认值?
不知道我哪里出错了.
我有以下代码,每1-2秒在页面上创建一个"气泡",然后在6秒后销毁每个气泡.
代码通常工作正常,除了尽管被初始化bubbleID显示的变量undefined.
function startBubbleMachine(){
var bubbleID = 1;
setInterval(function makeBubble(bubbleID){
var wh = randomInt(143, 50);
console.log('making bubble number '+bubbleID); // this shows undefined
$('.wrapper').append('<div class="db-bubble db-bubble-'+bubbleID+'" style="transform:rotate('+randomInt(20, 1)+'deg);left:'+randomInt(100, 1)+'%;width:'+wh+'px;height:'+wh+'px;"></div>');
killBubble(bubbleID);
bubbleID++; // this doesn't seem to get used
}, randomInt(2000, 1000));
}
Run Code Online (Sandbox Code Playgroud)
我正在初始化bubbleID为1:
var bubbleID = 1;
Run Code Online (Sandbox Code Playgroud)
我正在传递bubbleID函数内部setInterval
setInterval(function makeBubble(bubbleID){
...
});
Run Code Online (Sandbox Code Playgroud)
然后我在该函数中递增它:
bubbleID++;
Run Code Online (Sandbox Code Playgroud)
我哪里错了?
如何传递this给分配给我的事件的函数window.onscroll?
我试图myFunction()在满足特定条件时触发。我需要检查这个情况onscroll
init() {
window.onscroll = function() {
if(this.currentItemCount() > this.totalElements){
this.totalElements = this.currentItemCount();
this.myFunction();
}
};
}
Run Code Online (Sandbox Code Playgroud)
this.currentItemCount()但是我收到一个不是函数的错误。我知道我需要传递this给window.onscroll但我无法弄清楚正确的语法。
是否有类似的选项来删除正斜杠?
我有一个文本输入,可以是任何斜杠:
例如/ slug /或/ slug或slug or slug /
我需要完全删除所有正斜杠,无论它们在哪里.我知道stripslashes会为\ slash执行此操作.前锋有什么类似的吗?
目前我有:
$successful_slug = stripslashes($input_successful_slug);
Run Code Online (Sandbox Code Playgroud) 我试图在PHP中启动一个会话,以便存储有关用户ID的数据(将在mySQL DB中使用)。
但是,当我开始会话时,出现以下错误:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /Applications/MAMP/blah) in /Applications/MAMP/blah on line 38
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /Applications/MAMP/blah) in /Applications/MAMP/blah on line 38
Run Code Online (Sandbox Code Playgroud)
我了解错误是因为页面已提交或“标题已发送”而无法启动会话,但是我非常困惑,因为它所引用的行38行是启动会话的行:
Line 38: session_start();
Run Code Online (Sandbox Code Playgroud)
因此,如何说标头已经通过此行发送,这就是错误?
这是我的代码的简化部分。注意,HTML的一部分是通过jQuery使用AJAX加载的,是否可以?
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body>
<div class="wrapper">
<div id="quiz-section">
// This part is where the HTML content loads via AJAX
</div>
</div>
<!-- Below PHP looks at the referral …Run Code Online (Sandbox Code Playgroud) javascript ×4
php ×4
html ×3
jquery ×2
ajax ×1
css ×1
date ×1
draggable ×1
ecmascript-6 ×1
function ×1
innerhtml ×1
session ×1
stripslashes ×1
this ×1
variables ×1