我想知道是否可以用javascript打开文本文件(位置类似于:http://mysite.com/directory/file.txt)并检查文件是否包含给定的字符串/变量.
在php中,这可以通过以下方式轻松完成:
$file = file_get_contents("filename.ext");
if (!strpos($file, "search string")) {
echo "String not found!";
} else {
echo "String found!";
}
Run Code Online (Sandbox Code Playgroud)
有没有,最好是简单的方法来做到这一点?(我在nodejs,appfog上的.js文件中运行"function",如果可能的话).
什么是await外部应用程序创建文件最干净的方法?
async Task doSomethingWithFile(string filepath)
{
// 1. await for path exists
// 2. Do something with file
}
Run Code Online (Sandbox Code Playgroud) 所以我需要从特定类中获取内容并将其放在div中,我使用追加...我的问题是append删除了我追加的项目,我需要它留在那里,这是我的代码:
$(document).ready(function(){
var $content = $('#popupcontent');
var $window = $('#popupwindow');
$('.open').click(function(){
//alert('runnning');
var a = $(this).contents('span');
$content.append(a);
$window.fadeIn(300);
});
$('.close').click(function(){
//alert('running');
var a = $content.contents('span');
$window.fadeOut(300);
$('#popupcontent span').remove();
});
});
Run Code Online (Sandbox Code Playgroud)
所以,我怎么就能得到上述内容,点击后,从每一个.open span到#popupcontentsID,而无需从移除.open类?
告诉你我的意思:JSFIDDLE
注意:第二次单击链接时,它不会附加任何内容,因为该内容已从该类中删除,这不是我想要的
注2:我不能只是简单地append替代remove的$('.close').click功能,因为我无法检测到的哪个实例.open内容来自类.
我有这个mySQL脚本:
SELECT TOP 2 * FROM produse ORDER BY `id_produs` DESC
Run Code Online (Sandbox Code Playgroud)
生成此错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2 * FROM produse ORDER BY `id_produs` DESC LIMIT 0, 30' at line 1
Run Code Online (Sandbox Code Playgroud)
问题是什么?
假设我有一个如下定义的functionA:
functionA = function(myObject, someParams) {
myObject.save_some_data = someParams;
myObject.processed = true;
}
Run Code Online (Sandbox Code Playgroud)
然后我可以调用它并传递一个对象来处理functionA(someObject, someParams).
但是,我可以将此示例转换为apply():
functionA = function(someParams) {
this.save_some_data = someParams;
this.processed = true;
}
functionA.apply(someObject, [someParams]);
Run Code Online (Sandbox Code Playgroud)
这两种方法似乎都达到了同样的目标,或者我错过了什么?
但是既然apply()JavaScript中存在,那么使用它而不是让我的函数接受this作为第一个参数有什么好处?
我添加了一个自定义字段(产品负责人)TFS.由于我想要下载有效TFS用户,我复制了Assigned To控件的设置(String, Dimension, ALLOWEXISTINGVALUE, VALIDUSER).我希望能够设置一个警告:
Product Owner = [Me]
Run Code Online (Sandbox Code Playgroud)
但是equals不是运算符下拉列表中的可用选项.当我尝试设置警报时,我对此字段的唯一选择是Changes, Changes From, Changes To.
建议?谢谢,特洛伊
我正在使用jQuery mobile创建一个应用程序并加载其菜单和页面形式wordpress throw jsonp.我正在以collapsibleset和listview的形式取消其菜单,但我一直在收到错误.当我尝试通过此代码刷新collapsibleset时
$(".childnev").html(list);
$.mobile.loading( 'hide');
$('.popupmenu').slideToggle('slow');
$(".childnev").collapsibleset('refresh');
$(".childsublist").listview().listview('refresh');
Run Code Online (Sandbox Code Playgroud)
它给了我这个错误
Error: cannot call methods on collapsibleset prior to initialization;
attempted to call method 'refresh'
Run Code Online (Sandbox Code Playgroud)
当我尝试刷新此代码时.
$(".childnev").html(list);
$.mobile.loading( 'hide');
$('.popupmenu').slideToggle('slow');
$(".childnev").collapsibleset();
$(".childnev").collapsibleset('refresh');
$(".childsublist").listview().listview('refresh');
Run Code Online (Sandbox Code Playgroud)
它再次给了我这个错误
TypeError: o[0] is undefined
Run Code Online (Sandbox Code Playgroud)
我错过了什么或做错了什么?
jquery jquery-mobile jquery-mobile-listview jquery-mobile-collapsible
我将如何在jQuery中使用php值?我正在做的是使用php从数据库中提取增值税,如下所示并存储在$ vatrate中:
$sqlv = <<<SQL
SELECT *
FROM `vatrate`
WHERE id='1'
SQL;
if(!$resultv = $db->query($sqlv)){
die('There was an error running the query [' . $db->error . ']');
}
while($rowv = $resultv->fetch_assoc()){
$vatrate = $rowv['vatrate'];
} ?>
Run Code Online (Sandbox Code Playgroud)
然后我有我的jQuery脚本,它将所有行总数加在一起并将其放入一个范围内.
<script>
$(document).ready(function() {
$('input').on('keyup', function() {
var rawValue, grandtotal = 0;
$('span[id^="linetotal"]').each(function(i, elem) {
rawValue = $.trim($(this).text());
if (rawValue == '') rawValue = 0;
grandtotal += parseFloat(rawValue);
});
$('#grandtotal').text(grandtotal);
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
但是现在我不确定如何在jQuery中引用php中声明的$ vatrate值,这样我就能得到价格+增值税.增值税是不在英国的任何人的销售税:).
我收到了CSRF令牌错误..
TypeError: Cannot read property '_csrf' of undefined at Object.handle (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/middleware/csrf.js:45:28) at next (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/proto.js:190:15) at Object.session [as handle] (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/middleware/session.js:221:66) at next (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/proto.js:190:15) at Object.cookieParser [as handle] (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js:60:5) at next (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/proto.js:190:15) at Object.methodOverride [as handle] (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js:37:5) at next (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/proto.js:190:15) at Object.expressValidator [as handle] (/home/nodejs/sites/IcoderStuff/node_modules/express-validator/lib/express_validator.js:148:10) at next (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/proto.js:190:15)
"express": "3.0.3",
"less-middleware": "0.1.12",
"hbs": "2.3.0",
"express-validator": "0.4.1",
"mongoose" : "3.x",
"node-uuid" : "1.x",
"request" : "2.x",
"async" : "0.2.x",
"date-utils": "1.x",
"jade": "0.31.2",
"xml2js" : "0.2.7",
"MD5" : "1.0.3",
"csv" : "0.3.3", …Run Code Online (Sandbox Code Playgroud) 我有一个非常愚蠢的问题-.-以下:
<ul id="selectable" data-bind="foreach: folders">
<li>
<a href="#" data-bind=" text: $data, click: $root.goToFolder"></a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
它的KnockoutJS结合了一点SammyJS ... atm你看到我在'li'里面有一个'a'...所以鼠标悬停上会出现这个"手指"...但如果我删除了' a',ofc"手指"不会显示.相反它会出现这个(让我们称之为)文本编辑器光标......但是对于用户来说,他能够点击这个元素显然不是......有没有办法在链接悬停上显示这个"手指" ?
在这个例子中他们也有
<ul><li>Item</li></ul>
Run Code Online (Sandbox Code Playgroud)
它显示了这个"手指"
javascript ×3
jquery ×3
.net ×1
append ×1
async-await ×1
c# ×1
css ×1
database ×1
express ×1
html ×1
html-lists ×1
knockout.js ×1
mysql ×1
node.js ×1
php ×1
select ×1
sql ×1
tfs-alerts ×1
tfs2012 ×1
variables ×1