我正在使用此脚本上传我的图像文件:http://jsfiddle.net/eHmSr/
$('.uploader input:file').on('change', function() {
$this = $(this);
$('.alert').remove();
$.each($this[0].files, function(key, file) {
$('.files').append('<li>' + file.name + '</li>');
data = new FormData();
data.append(file.name, file);
$.ajax({
url: $('.uploader').attr('action'),
type: 'POST',
dataType: 'json',
data: data
});
});
});
Run Code Online (Sandbox Code Playgroud)
但是当我点击上传按钮时,JavaScript控制台会返回以下错误:
Uncaught TypeError: Illegal invocation
Run Code Online (Sandbox Code Playgroud)
你能帮助我吗?
我正在新的macOS Sierra setting中建立我的开发环境.
首先,我安装了Rbenv,Ruby(2.3.1),Homebrew等最新版本的MySQL(5.7.15).
$ brew install mysql
$ mysql.server start
Run Code Online (Sandbox Code Playgroud)
好的,MySQL已初始化.是时候安装mysql2 gem了......
$ gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.7.15/bin/mysql_config
Run Code Online (Sandbox Code Playgroud)
但它没有用.
Building native extensions with: '--with-mysql-config=/usr/local/Cellar/mysql/5.7.15/bin/mysql_config'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /Users/macuser/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mysql2-0.4.4/ext/mysql2
/Users/macuser/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20160921-16853-x1boio.rb extconf.rb --with-mysql-config=/usr/local/Cellar/mysql/5.7.15/bin/mysql_config
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... …
Run Code Online (Sandbox Code Playgroud) 我正在学习HTML5中的历史,在这个例子中(打开JavaScript浏览器控制台以查看错误)event.state.url
返回:
Uncaught TypeError: Cannot read property 'url' of undefined
Run Code Online (Sandbox Code Playgroud)
看看和帮助:http://jsfiddle.net/un4Xk/
我可以用Ruby测量两个字符串之间的距离吗?
即:
compare('Test', 'est') # Returns 1
compare('Test', 'Tes') # Returns 1
compare('Test', 'Tast') # Returns 1
compare('Test', 'Taste') # Returns 2
compare('Test', 'tazT') # Returns 5
Run Code Online (Sandbox Code Playgroud) 我试图在SCSS中以这种方式使用filter mix:
a {
@include filter(grayscale(100%));
}
Run Code Online (Sandbox Code Playgroud)
但是当我编译时,我收到了这个错误:
Undefined mixin 'filter'.
Run Code Online (Sandbox Code Playgroud)
我正在使用这个带有Rails框架的Gem的最新版本.
在旋转动画中,适用于Chrome但不适用于Firefox.为什么?
@-moz-keyframes rotate {
from { -moz-transform: rotate(0deg); }
to { -moz-transform: rotate(360deg); }
}
@-webkit-keyframes rotate {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
#example {
background: red;
width: 100px;
height: 100px;
-moz-animation: rotate 20s linear 0 infinite;
-webkit-animation: rotate 20s linear 0 infinite;
}
Run Code Online (Sandbox Code Playgroud)
我知道两种方法来检索Facebook上的评论数量:
<fb:comments-count href=http://example.com/></fb:comments-count> awesome comments
Run Code Online (Sandbox Code Playgroud)
和...
<iframe src="http://www.facebook.com/plugins/comments.php?href=example.com&permalink=1" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:130px; height:16px;" allowTransparency="true"></iframe>
Run Code Online (Sandbox Code Playgroud)
但是没有一个是HTML5解决方案的语义,还有其他选择吗?
我想创建一个函数createAssociativeArray
,它将返回两个参数:string
和object
,像这样:
function createAssociativeArray(string, object) {
//...
}
Run Code Online (Sandbox Code Playgroud)
最后一项string
应该获取object
数据.查看使用/返回示例:
createAssociativeArray('key1.key2.key3', {
data1: 1,
data2: 2,
data3: 3
});
// key1: {
// key2: {
// key3: {
// data1: 1,
// data2: 2,
// data3: 3
// }
// }
// }
Run Code Online (Sandbox Code Playgroud)
什么是最简单,最健壮的方法?
使用eval不是可能的.
我尝试了什么:
function createAssociativeArray(string, object) {
string = string.split('.');
return string.reduce(function(_object, _target, i) {
_object[_target] = (i + 1 === string.length ? object : {});
return …
Run Code Online (Sandbox Code Playgroud) 我正在做一个项目列表,但它有一些挑战:
这是我所期待的形象:
我得到了什么:http://codepen.io/caio/pen/ygkfm/
如您所见,div
当有图标时,我无法将相同的缩放设置为"图像" .我的问题有什么解决方案吗?
我有一个上传字段的网站,但input
隐藏了display: none;
,我有一个div
用于调用此操作.
它适用于iOS 8,但现在在iOS 9更新后,当我触摸div时没有任何反应.
我尝试使用[0].click()
或纯粹的VanillaJS document.getElementById('file_input').click()
,没有任何作用.
所有这些方法都适用于iOS 5和iOS 8.
如果你愿意,可以在JSFiddle上链接到这个例子: https ://jsfiddle.net/o1r265tz/6/embedded/result/
$(document).ready(function(){
$(document).on('click touchstart', '.upload-box', function(e){
e.stopPropagation();
$('.form-upload input.file-input').trigger('click');
$('.debug').append('<p>Clicked!</p>');
console.log('Clicked!');
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
.upload-box {
border: 3px solid #999;
padding: 10px;
text-align: center;
border-radius: 5px;
font-size: 35pt;
font-family: Arial;
color: #555;
}
.form-upload {
display: none;
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="upload-box">Click here to upload =D</div>
<form class="form-upload" enctype="multipart/form-data">
<input class="file-input" id="file_input" type="file">
</form>
<div class="debug"></div>
Run Code Online (Sandbox Code Playgroud)