我不知道我的数据语法是否错误,但是当没有传递参数时这个相同的脚本正在工作,但是当传递参数时,它不起作用.为什么?
<script type="text/javascript" src="jquery-1.7.2.min.js">
<script type="text/javascript">
function GetAge() {
var StrYear = document.getElementById("StringYear").value;
var StrMonth = document.getElementById("StringMonth").value;
var StrDay = document.getElementById("StringDay").value;
jQuery.support.cors = true;
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
jsonp: 'jsonp_callback',
async: false,
url: 'http://localhost:50113/Service1.asmx/GetAge',
data: "{ StrYear: "+StrYear+", StrMonth:"+ StrMonth+" , StrDay: "+StrDay+" }",
success: function (msg) {
$('#divToBeWorkedOn').html(msg.d);
},
error: function (e) {
$('#divToBeWorkedOn').html("Unavailable");
}
});
}
</script>
Run Code Online (Sandbox Code Playgroud) 我试图timeNow在javascript和脚本结束时获取当前时间获取
timeEnd脚本完成执行的时间,例如:
newDate = new Date();
timeNow = newDate.getTime();
for(i=0; i < 5; i ++){
console.log("printing" + i);
}
timeEnd = timeNow - newDate.getTime();
console.log(timeEnd);
Run Code Online (Sandbox Code Playgroud)
我希望得到在几秒或几毫秒内执行此脚本所花费的时间,但结果为0.我不明白为什么,你能帮我谢谢.
我试图使用for循环声明变量,然后测试cols和rols是否相同.如果是,它将运行递归函数.但是,我在javascript中做的很麻烦.有人可以帮忙吗?
现在,它说,意想不到的变化==进行比较时,col.1和col.2.我也尝试col+j过for循环,但确实如此invalid left-hand side assignment
for (var i = 0; i < 2; i++) {
var col = {};
col.i = Math.floor(Math.random() * cols);
col.i = Math.floor(Math.random() * rows);
}
if (col.1 == col.2 && row.1 == row.2) {
return this.getRandomBlock();
}
Run Code Online (Sandbox Code Playgroud) 当您收到1条通知或消息时,如何更改Facebook上将标题更改为“(1)Facebook”的方式显示在浏览器选项卡上的网站的当前标题?
当我们调用此命令时rails runner test.rb -e production,我们看到此错误:
test.rb:2:in `<top (required)>': undefined local variable or method `hello' for main:Object (NameError)
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands/runner.rb:51:in `eval'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands/runner.rb:51:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:64:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:64:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Run Code Online (Sandbox Code Playgroud)
test.rb的内容:
hello
def hello
puts "hi"
end
Run Code Online (Sandbox Code Playgroud)
为什么会这样?我们在Rails 3.2.12上.