xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
}
}
Run Code Online (Sandbox Code Playgroud)
以上代码来自:http://www.w3schools.com/ajax/ajax_xmlhttprequest_onreadystatechange.asp.
题:
根据本教程:
readyState: 4: request finished and response is ready
status: 200: "OK"
When readyState is 4 and status is 200, the response is ready:
Run Code Online (Sandbox Code Playgroud)
从什么时候开始xmlhttp.readyState == 4,响应准备就绪,我们为什么还需要xmlhttp.status == 200?xmlhttp.readyState == 4和之间有什么区别xmlhttp.status == 200?
我想将这个文件夹:ajax(/ home/thej/public_html/JC/ajax)复制到这个文件夹中:/home/thej/public_html/demo/conf/最后的结果是 /home/thej/public_html/demo/conf/ajax,我知道cp命令应该是这样的:
cp -r /home/thej/public_html/JC/ajax /home/thej/public_html/demo/conf
我的问题是:
我应该把/后ajax,ajax/?
我应该把/后conf,conf/?
我在网上搜索,有些放'/',有些没有,所以真的很困惑.
<script type="text/javascript">
function saveName (firstName) {
function capitalizeName () {
return firstName.toUpperCase();
}
var capitalized = capitalizeName();console.log(capitalized instanceof String);
return capitalized;
}
console.log(saveName("Robert")); // Returns "ROBERT"
</script>
Run Code Online (Sandbox Code Playgroud)
题:
我想检查大写的类型,所以我使用capitalized instanceof String?但它显示:false在控制台中,我不想尝试capitalized instanceof Function,Object...这将花费太多时间,那么检测变量类型的最佳方法是什么?
<input type="button" value="Button 1" id="btn1" />
<input type="button" value="Button 2" id="btn2" />
<input type="button" value="Button 3" id="btn3" onclick="buttonClicked();"/>
<script type="text/javascript">
function buttonClicked(){
var text = (this === window) ? 'window' : this.id;
console.log( text);
}
var button1 = document.getElementById('btn1');
var button2 = document.getElementById('btn2');
button1.onclick = buttonClicked;
button2.onclick = function(){
buttonClicked();
};
</script>
Run Code Online (Sandbox Code Playgroud)
题:
当点击button1,显示:btn1,点击button2和button3,显示:window,为什么不btn2,btn3?
我试图找到所有文件都有文字:$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'],我试图使用grep -rl '$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']' .,但后来发现[]有特殊意义的搜索模式.那么搜索文本的正确命令是$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']什么?
<style>
body { margin: 10px }
</style>
<body>
<script>
console.log(document.body.style.marginTop);
</script>
</body>
Run Code Online (Sandbox Code Playgroud)
题:
在firefox-> console中显示:(an empty string),为什么?
从本教程中可以看出:
preventDefault();做一件事:它停止了浏览器的默认行为.
我在网上搜索了一些例子preventDefault(),我只能看到我们使用的两种情况(链接,表单)preventDefault():阻止提交按钮提交表单并防止链接跟随URL.
所以,我的问题是:
在其他情况下我们可以使用preventDefault()?
我怎么能找出所有浏览器的默认行为?例如,如果我单击一个按钮,浏览器的默认行为是什么?
我认为通常我们使用静态方法,因为我们不需要实例化对象.我们可以className::staticFunction用来调用静态方法,今天发现bub:
<?php
class Foo {
static public function helloWorld() {
print "Hello world " ;
}
}
Foo::helloWorld();
Run Code Online (Sandbox Code Playgroud)
<?php
class Foo {
public function helloWorld() {
print "Hello world " ;
}
}
Foo::helloWorld();
Run Code Online (Sandbox Code Playgroud)
题:
以上两个脚本都有效.我们没有声明函数static,我们仍然可以className::staticFunction用来调用函数.为什么我们需要使用静态方法?
CSS:
h1 {color:#000;}
Run Code Online (Sandbox Code Playgroud)
HTML:
<h1>This is heading 1</h1>
Run Code Online (Sandbox Code Playgroud)
题:
color:#000;(十六进制颜色值)和color:#000000(十六进制颜色值)之间有什么区别吗?
我想找到哪个页面安装了这个扩展名:jc_register,我可以查看每个页面,但由于页面很多,所以需要花费太多时间,所以我想知道是否有任何快速的方法来查找它而不是检查每个页面?
我总是在科技文章中看到 parse或compile发表文章。所以我想知道PHP是如何工作的。我发现PHP是解释性语言,没有编译。我GOOGLE了网上有关parse,Interpret和compile,但仍然没有说清楚的全过程。以下是示例PHP代码:
<?php
$str1="Hello world!";
$str2="What a nice day!";
echo $str1 . " " . $str2;
?>
Run Code Online (Sandbox Code Playgroud)
输出:
Hello world! What a nice day!
Run Code Online (Sandbox Code Playgroud)
谁能解释从源代码到输出的整个过程(解析,解释...)?谢谢
<?php
$d = dir('css');
echo "Handle: " . $d->handle . "<br>";
echo "Path: " . $d->path . "<br>";
while (($file = $d->read()) !== false){
echo "filename: " . $file . "<br>";
}
$d->close();
?>
Run Code Online (Sandbox Code Playgroud)
结果:
Handle: Resource id #4
Path: css
filename: .
filename: ..
filename: css
filename: img
filename: index.html
filename: js
filename: lightbox
Run Code Online (Sandbox Code Playgroud)
题:
在结果中,做什么.和..意味着什么?