如何使用javascript历史API(How to use javascript history API)
在github的博客文章中,他们如何创建新的树滑块,他们将此作为使用的代码:
$('#slider a').click(function() { history.pushState({ path: this.path }, '', this.href) $.get(this.href, function(data) { $('#slider').slideTo(data) }) return false })
但是,我不知道这是如何工作的? 他们AJAX请求整个新页面,所以从
<html>
到</html>
包含,然后看似(使用一个名为'slideTo'的方法)将这些数据放入滑块元素? 当然,你最终会在页面内找到一个页面(很可能是CSS故障)。如何使用AJAX和History API,您是否只获得已更改的特定部分? 或者是替换了html代码(但在上例中并非如此)?
实际的javascript github在哪里使用? 我是对的,所给出的例子不能被使用,因为它不能正常工作?
In github's blog post about how they created the new tree slider, they give this as the code used:
$('#slider a').click(function() { history.pushState({ path: this.path }, '', this.href) $.get(this.href, function(data) { $('#slider').slideTo(data) }) return false })
However I don't see how this works? They AJAX request the whole new page, so from
<html>
to</html>
inclusive, then seemingly (using a method called 'slideTo'??) put this data into the slider element? Surely then you'd end up with a page within a page (likely with CSS glitches).How when using AJAX and History API, do you get only the specific section that has changed? Or is it that the html code is replaced (but this is not the case in the above example)?
Where is the actual javascript github uses? And am I right that the example given can't be what is used as it won't work properly?
原文:https://stackoverflow.com/questions/6078645
最满意答案
perldoc strict将显示未使用
my
声明的所有变量:$ perl -Mstrict=vars -c -e '$x=5; my $y=7; $z=6;' Global symbol "$x" requires explicit package name at -e line 1. Global symbol "$z" requires explicit package name at -e line 1. -e had compilation errors.
与文件列表相同:
$ perl -Mstrict=vars -c *.pl
这是另一种使用perldoc B :: Xref的方法
$ perl -MO=Xref -e '$x=5; my $y=7; $z=6;' ... lots of verbose output Subroutine (main) Package (lexical) $y i1 Package main $x 1 $z 1
perldoc strict will show all variables not declared with
my
:$ perl -Mstrict=vars -c -e '$x=5; my $y=7; $z=6;' Global symbol "$x" requires explicit package name at -e line 1. Global symbol "$z" requires explicit package name at -e line 1. -e had compilation errors.
The same thing with a list of files:
$ perl -Mstrict=vars -c *.pl
Here is another way using perldoc B::Xref
$ perl -MO=Xref -e '$x=5; my $y=7; $z=6;' ... lots of verbose output Subroutine (main) Package (lexical) $y i1 Package main $x 1 $z 1
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
调用子程序时,您的变量不会被声明: &ArgParser; # subroutine call our ($sqluser,$sqlpass); # declaration $sqluser="root"; # assignment $sqlpass="mypassword"; 为了在子程序中使用这些全局变量,把子程序放在变量声明之后。 但是,使用全局变量是一件坏事,你应该尽可能避免它。 你可以这样做,例如: my $sqluser = "ro ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
参见perldoc perlrun : 如果程序在语法上是正确的,则执行该程序。 如果程序在不碰到exit()或die()运算符的情况下运行结束,则会提供隐式exit(0)以指示成功完成。 因此,您正在运行的程序必须以某种方式通过死亡 , 退出或等效方式指定这些退出值。 See perldoc perlrun: If the program is syntactically correct, it is executed. If the program runs off the end without hi ...
-
听起来你会对Inline模块感兴趣。 它允许Perl以许多其他语言调用代码,并依赖于每种语言的支持模块。 你没有说你想做什么,但你提到了Python,并且有一个Inline::Python 。 It sounds like you would be interested in the Inline module. It allows Perl to call code in many other languages, and relies on support modules for each langua ...
-
将.exe重命名为.zip并检查是否可以提取文件 Rename .exe to .zip and check if files can be extracted
-
exec('perl perl_tests\hello.pl arg1 arg2 arg3 ....')就可以了。 经过一分钟的谷歌搜索: http : //www.ryerson.ca/perl/runningAScript.html 。 底部有一个命令行条目。 exec('perl perl_tests\hello.pl arg1 arg2 arg3 ....') will do the trick. After a minute of googling: http://www.ryerson.ca/p ...
-
perldoc strict将显示未使用my声明的所有变量: $ perl -Mstrict=vars -c -e '$x=5; my $y=7; $z=6;' Global symbol "$x" requires explicit package name at -e line 1. Global symbol "$z" requires explicit package name at -e line 1. -e had compilation errors. 与文件列表相同: $ perl -Ms ...
-
那个模块坏了。 寻找替代方案。 它自2008年以来一直没有更新,并且不再与任何当前版本的PHP兼容。 That module is broken. Find an alternative. It hasn't been updated since 2008, and is no longer compatible with any current version of PHP.
-
有没有办法通过某些环境变量调用Perl调试器?(Is there a way to invoke Perl debugger by some environment variables?)[2022-07-03]
将PERL5OPT环境变量设置为'-d': $ export PERL5OPT=-d $ ./test.pl Loading DB routines from perl5db.pl version 1.3 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(./test.pl:3): print "Hello\n"; DB<1> r Hello Set ...