希望这对于某人来说是一个快速而简单的方法.我使用大量的javascript/jquery相当新,我有以下设置从数据库中提取客户名称并在用户输入客户ID时显示它.
一切都很好,但它会搜索每个密钥.我知道我可以把它改成模糊,但是我希望它能够在延迟时进行搜索.
这是当前的代码:
function postData(){
var id = $('#id').val();
$.post('inc/repairs/events-backend.php',{id:id},
function(data){
$("#display_customer").html(data);
});
return false;
}
$(function() {
$("#id").bind('keyup',function() {postData()});
});
Run Code Online (Sandbox Code Playgroud)
正如您所看到的那样,它绑定到每个keyup,这意味着如果您搜索得太快,可能会因为它仍然被加载而导致错误的结果.(即如果没有找到匹配项,则会显示错误,并且输入足够快会使用户需要退格并重新键入最后一个数字)
有人可以协助为现有代码添加延迟,并且如果可能的话,对您所做的更改进行一些小的解释,我不仅仅是在不理解的情况下进行复制和粘贴.
----编辑----
这是我完成的代码,谢谢你们!
function postData(){
var id = $('#id').val();
$.post('inc/repairs/events-backend.php',{id:id},
function(data){
$("#display_customer").html(data);
});
return false;
}
$(function() {
var timer;
$("#id").bind('keyup input',function() {
timer && clearTimeout(timer);
timer = setTimeout(postData, 300);
});
});
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我使用Android设备相机捕获我的图像.在某些设备上它工作正常,但不是全部,我只是测试了LG nexus 5 E960,在我捕获图像后它总是结束崩溃而无法保存结果这是我的代码:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, 1);
protected void onActivityResult(int requestCode, int resultCode,
Intent returnimage) {
super.onActivityResult(requestCode, resultCode, returnimage);
switch (requestCode) {
case 1:
if (resultCode == RESULT_OK) {
Uri selectedImage = returnimage.getData();
String stringUri;
stringUri = selectedImage.toString();
Intent i1 = new Intent(MainActivity.this, Secondpage.class);
i1.putExtra("Stringuri",stringUri );
startActivity(i1);
}
break;
Run Code Online (Sandbox Code Playgroud)
我的logcat是:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null,
request=1, result=-1, data=Intent { act=inline-data (has extras) }} to activity
{com.photostikers/com.photostikers.MainActivity}: java.lang.NullPointerException
02-13 12:27:54.315: E/AndroidRuntime(28759): at
android.app.ActivityThread.deliverResults(ActivityThread.java:3365)
02-13 12:27:54.315: E/AndroidRuntime(28759): at …
Run Code Online (Sandbox Code Playgroud) 有些日子我一直在使用http://www.mamp.info上的 MAMP Pro 3.07 .伟大的工具,一切正常.但现在我遇到了问题,对于一个新项目我需要连接到MSSQL.
我在www中搜索了最后3个小时的howto,但找不到合适的答案或者我是不是很蠢?
是否有可能在OSX Yosemite上的MAMP上安装"PDO-dblib"?
或者有人可以解释我怎么做到这一点?
提前致谢!
我已经下载了Angular 5 / .NET 5 项目,通常当我运行命令 npm install 时,没有任何问题。
但从昨天开始,当下载项目并运行此命令时,我收到此错误:
C:\Users\ca\source\repos\CCM\angular\src>npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: CCM@4.7.1
npm ERR! Found: @angular/compiler@10.2.1
npm ERR! node_modules/@angular/compiler
npm ERR! @angular/compiler@"^10.2.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@">=2.3.1 <10.0.0 || >9.0.0-beta <10.0.0 || >9.1.0-beta <10.0.0 || >9.2.0-beta <10.0.0" from codelyzer@5.2.2
npm ERR! node_modules/codelyzer
npm ERR! dev codelyzer@"^5.1.2" from the …
Run Code Online (Sandbox Code Playgroud) 我试图获得一个大数字的日志。我该怎么做?我不能使用 gmp.hpp 因为它说Cannot open include file: 'gmp.h': No such file or directory
以下代码
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#define rsa100 "1522605027922533360535618378132637429718068114961380688657908494580122963258952897654000350692006139"
using namespace std;
using namespace boost::multiprecision;
int main(){
cpp_int n(rsa100);
cout << boost::multiprecision::log(n);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
给我错误:
1>------ Build started: Project: rsa, Configuration: Debug x64 ------
1> Source.cpp
1>Source.cpp(12): error C2893: Failed to specialize function template 'enable_if_c<boost::multiprecision::number_category<Num>::value==1,boost::multiprecision::detail::expression<boost::multiprecision::detail::function,boost::multiprecision::detail::log_funct<Backend>,boost::multiprecision::number<B,et_on>,void,void>>::type boost::multiprecision::log(const boost::multiprecision::number<B,et_on> &)'
1> With the following template arguments:
1> 'Backend=boost::multiprecision::backends::cpp_int_backend<0,0,signed_magnitude,unchecked,std::allocator<boost::multiprecision::limb_type>>'
1>Source.cpp(12): error C2784: 'enable_if_c<boost::multiprecision::number_category<boost::multiprecision::detail::expression<tag,Arg1,Arg2,Arg3,Arg4>>::value==number_kind_floating_point,boost::multiprecision::detail::expression<boost::multiprecision::detail::function,boost::multiprecision::detail::log_funct<detail::backend_type<boost::multiprecision::detail::expression<tag,Arg1,Arg2,Arg3,Arg4>>::type>,boost::multiprecision::detail::expression<tag,Arg1,Arg2,Arg3,Arg4>,void,void>>::type boost::multiprecision::log(const boost::multiprecision::detail::expression<tag,Arg1,Arg2,Arg3,Arg4> &)' : could not deduce …
Run Code Online (Sandbox Code Playgroud) 首先,我对C#并不是那么好,自从我使用它以来已经有一段时间了.
我正在为一个提供包裹的朋友制作一个Windows窗体.因此,我想将他当前的论文表格转换为带有iTextSharp库的.pdf.他仍然需要打印表格以获得客户签名等.
我需要的是: 我希望表格有一个标题,"公司名称",例如,文本应该比从Windows窗体输入的文本小一点(richTextBox1)
目前我正在使用单元格,并想知道我是否可以在同一个单元格中使用2种不同的字体大小?
是)我有的:
table.AddCell("Static headline" + Chunk.NEWLINE + richTextBox1.Text);
Run Code Online (Sandbox Code Playgroud)
我想要的是":
var normalFont = FontFactory.GetFont(FontFactory.HELVETICA, 9);
var boldFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12);
table.AddCell("Static headline", boldFont + Chunk.NEWLINE + richTextBox1.Text, normalFont);
Run Code Online (Sandbox Code Playgroud) 我正在尝试保存我的IContent
呼叫child
,但在这一行(contentService.SaveAndPublish(child);
)上我收到以下错误:Object reference not set to an instance of an object.
if (child.HasProperty("navn"))\n{\n child.SetValue("navn", worker.Name.ToString(), "da-dk");\n}\ncontentService.SaveAndPublish(child);\n
Run Code Online (Sandbox Code Playgroud)\n\n这就是我定义我的contentService
:IContentService contentService = Umbraco.Core.Composing.Current.Services.ContentService;
我发现孩子们是这样的:
\n\nlong totalChildren;\n\nIEnumerable<IContent> children = contentService.GetPagedChildren(filialsParent.Id, 0, 100, out totalChildren);\n
Run Code Online (Sandbox Code Playgroud)\n\n\xc2\xb4\n有人能指出这里出了什么问题吗?
\n我想在 IDL 文件中定义几个结构。然后在服务中返回该结构类型的对象。为此,我必须导入该结构。如何在 IDL 中导入它们。
namespace java abc.xyz
struct struct_{
1:string s
2:bool b
}
service struct_test{
struct_ getstruct_()
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个简单的页面,其中包含使用材料精简版设计的卡片,但是一个问题卡住了页面的整个布局。如何将MDL卡对准 屏幕的右侧?我已经尝试过float:right; 在css中,则卡仅在同一列中向右移动,而不在屏幕上移动。帮我转移
<div class="mdl-cell mdl-cell--6-col">
<div class="demo-card-wide mdl-card mdl-shadow--2dp">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Welcome</h2>
</div>
<div class="mdl-card__supporting-text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Mauris sagittis pellentesque lacus eleifend lacinia...
</div>
<div class="mdl-card__actions mdl-card--border">
<a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">
Get Started
</a>
</div>
<div class="mdl-card__menu">
<button class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect">
<i class="material-icons">share</i>
</button>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我的桌子上有一个复选框.这是该复选框的CSS
input[type="checkbox"] {
width: 20px;
height: 30px;
margin: auto;
display: table-row;
border: 5px solid red;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
margin-left: 4px;
margin-top: 1px;
}
Run Code Online (Sandbox Code Playgroud)
但它显示正常的复选框.我想更改该复选框的边框颜色.但它不起作用!