我创建了一个名为'loaded'的属性按钮,初始值为'no'.点击按钮我正在运行一些ajax,在它的最后我试图将'loaded'属性设置为'yes',这样如果用户不止一次点击按钮,ajax就不会再次运行.
我有这样的事情:http://jsfiddle.net/PDW35/2/
单击该按钮不会更改加载到"是".但是,如果您在.attr调用之后立即执行警报,请执行以下操作:
alert($(this).attr('loaded'));
Run Code Online (Sandbox Code Playgroud)
警报框确实包含"是",这没有用,因为一旦用户点击,上面的相同代码会在屏幕上显示"否"警告框.
如果我使用.prop而不是.attr,它的行为都是一样的.我在这里错过了一点或.prop和.attr只是不使用自定义属性?
编辑:根据以下评论使用ajax更新了jsfiddle:http://jsfiddle.net/PDW35/5/
我有一个名为Time的TimeSpan变量,我设法在XAML中成功绑定.这是我的代码:
...
<TextBlock Grid.Column="2" Text="{Binding Time, StringFormat='{}{0:hh:mm}'}" />
...
Run Code Online (Sandbox Code Playgroud)
现在可以正确显示这些值,但格式仍为hh:mm:ss.我试图摆脱秒并只显示小时和分钟,但由于某种原因,我对StringFormat所做的更改没有考虑到,我总是得到相同的hh:mm:ss格式.你能给些建议么?
谢谢!
编辑:
根据下面的评论判断,我绑定的时间似乎不是TimeSpan格式,因为StringFormat似乎是正确的,但显示的值是错误的.Time变量在自定义类Record中定义如下:
private TimeSpan time;
public TimeSpan Time
{
get { return time; }
set { time = value; }
}
Run Code Online (Sandbox Code Playgroud)
在我的代码中,我定义了一个可观察的集合:
ObservableCollection<Record> records = new ObservableCollection<Record>();
Run Code Online (Sandbox Code Playgroud)
该集合是填充的,然后我有:
listBoxRecords.ItemsSource = this.records;
Run Code Online (Sandbox Code Playgroud)
这是完整的XAML,请记住其余的字段都已正确填充,只有TimeSpan给我带来麻烦:
<ListBox Margin="0,44,0,58" Name="listBoxRecords" ItemsSource="{Binding records}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
<ColumnDefinition Width="85" />
<ColumnDefinition Width="55" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Date, StringFormat='{}{0:dd-MM-yyyy HH:mm}'}" />
<TextBlock Grid.Column="1" Text="{Binding Type }" />
<TextBlock Grid.Column="2" Text="{Binding Time, StringFormat='{}{0:hh\\:mm}'}" …Run Code Online (Sandbox Code Playgroud) 我在与简单 USB 设备通信的 WPF 应用程序中使用 LibUSBDotNet 库。我只向设备发送 3 个字节作为命令,没有预期的响应,我的代码就像一个魅力:
MyUsbFinder = new UsbDeviceFinder(vid, pid);
MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder);
wholeUsbDevice = MyUsbDevice as IUsbDevice;
if (!ReferenceEquals(wholeUsbDevice, null))
{
wholeUsbDevice.SetConfiguration(1);
wholeUsbDevice.ClaimInterface(0);
}
writer = MyUsbDevice.OpenEndpointWriter(WriteEndpointID.Ep01);
Run Code Online (Sandbox Code Playgroud)
然后是写入设备的过程:
byte[] update = { 0x21, some_code_generated_byte, some_code_generated_byte };
int bytesWritten;
if (MyUsbDevice != null)
{
ec = writer.Write(update, 2000, out bytesWritten);
}
Run Code Online (Sandbox Code Playgroud)
我对使用 USB 还比较陌生,但到目前为止我已经掌握了一切,而且一切正常。但是,一段时间后,在尝试再次写入设备时,我会时不时地遇到以下两个错误之一:
Win32Error:GetOverlappedResult Ep 0x01
31:The parameter is incorrect.
Win32Error:PipeTransferSubmit Ep 0x01
87:The parameter is incorrect.
Run Code Online (Sandbox Code Playgroud)
通常我需要重新启动设备/应用程序几次,然后它才能再次开始工作,然后在它再次发生之前又像魅力一样工作了几个小时......到目前为止,我也无法在测试环境中复制崩溃.
我做了很多研究,试图找到与我类似的问题/解决方案,但没有成功。我留下的唯一建议是,在某些时候设备没有足够的电量,它会进入这种错误模式,但即使这样似乎也不太可能,因为它有一个单独的 12V 电源,它所做的只是打开和关闭几个继电器...
我还尝试用大量连续命令一个接一个地淹没设备,包括垃圾命令,但它仍然可以正常工作并且行为正常,只是稍后会崩溃。
欢迎任何建议或想法,谢谢!
编辑:经过多次尝试后,我仍然无法确定问题的根本原因,但我设法达到了代码正常工作的程度,并且能够使用尝试重置设备的重新连接功能从 OverlappedResult …
如何在Windows-32位上安装openSSL?
到目前为止,这是我所做的:
从http://www.openssl.org/source/下载的openSSL源代码,并使用7-zip解压缩
下载并安装ActiveState Perl @ ActiveState Perl并添加C:\perl\bin\。
运行C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat以获取Visual Studio环境安装程序。
运行perl Configure VC-WIN32 no-asm – -prefix=C:\openssl-1.0.1b。
这个命令给我错误cannot open perl script "Configure": no such file or directory。
请帮我解决这个问题。
我加载了我训练的模型。这是培训的最后一层:
model.add(Flatten())
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(3))
model.add(Activation('sigmoid'))
model.compile(loss='categorical_crossentropy',
optimizer='adam',
metrics=['accuracy'])
Run Code Online (Sandbox Code Playgroud)
之后,我尝试对随机图像进行预测。所以我加载模型:
#load the model we created
json_file = open('/path/to/model_3.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)
# load weight into model
loaded_model.load_weights("/path/to/model_3.h5")
print("\nModel successfully loaded from disk! ")
# Predicting images
img =image.load_img('/path/to/image.jpeg', target_size=(224, 224))
x = image.img_to_array(img)
x *= (255.0/x.max())
image = np.expand_dims(x, axis = 0)
image = preprocess(image)
preds = loaded_model.predict_proba(image)
pred_classes = np.argmax(preds)
print(preds)
print(pred_classes)
Run Code Online (Sandbox Code Playgroud)
作为输出,我得到这个:
[[6.0599333e-26 0.0000000e+00 1.0000000e+00]]
2
Run Code Online (Sandbox Code Playgroud)
基本上就像我得到的[0 0 1]
那样predict_classes …
在WPF应用程序中使用USB设备,我可以成功连接并向设备发送命令.设备只接收命令,没有回复,所以我需要的是一个与之通信的EndpointWriter.
MyUsbFinder = new UsbDeviceFinder(vid, pid);
MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder);
wholeUsbDevice = MyUsbDevice as IUsbDevice;
if (!ReferenceEquals(wholeUsbDevice, null))
{
wholeUsbDevice.SetConfiguration(1);
wholeUsbDevice.ClaimInterface(0);
}
writer = MyUsbDevice.OpenEndpointWriter(WriteEndpointID.Ep01);
Run Code Online (Sandbox Code Playgroud)
然后写入设备的过程:
byte[] update = { some bytes };
int bytesWritten;
if (MyUsbDevice != null)
{
ec = writer.Write(update, 2000, out bytesWritten);
}
Run Code Online (Sandbox Code Playgroud)
一切正常,包括关闭应用程序,除非在工作过程中USB设备断开然后重新连接.应用程序成功处理此方案并重新连接到设备,继续成功向其发送命令:
public bool reconnect()
{
//clear the info so far
if (MyUsbDevice != null)
{
writer.Dispose();
wholeUsbDevice.ReleaseInterface(0);
wholeUsbDevice.Close();
MyUsbDevice.Close();
UsbDevice.Exit();
}
//now start over
MyUsbFinder = new UsbDeviceFinder(vid, pid);
MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder);
Run Code Online (Sandbox Code Playgroud)
......等等.
在发生此类断开/重新连接后关闭应用程序时会发生此问题.虽然该程序成功运行并与设备通信了很长一段时间,但在退出时我得到以下异常: …
我已经使用自定义操作设置了 Yii2 REST API,一切工作正常。然而,我想做的是从 API 返回一些数据,其中包括由外键设置的数据库关系。这些关系是存在的,而且它们实际上运行正常。以下是其中一个控制器中的查询示例:
$result = \app\models\Person::find()->joinWith('fKCountry', true)
->where(..some condition..)->one();
Run Code Online (Sandbox Code Playgroud)
例如,仍然在控制器中,我可以调用如下内容:
$result->fKCountry->name
Run Code Online (Sandbox Code Playgroud)
当关系有效时,它会显示适当的名称。到目前为止一切顺利,但是一旦我返回return $result;从 API 客户端收到的结果,该结果fkCountry就消失了,我无法访问上面提到的名称。唯一剩下的就是指向国家/地区表的外键值。
我可以提供更多代码和信息,但我认为这足以描述问题。如何对返回的连接数据中的信息进行编码,以便 API 客户端也可以访问它?
我正在努力获得正确的jQuery选择器来点击某个元素.这是我的HTML:
<label class="title-label" for="me">Some Title<i class="fa fa-times del-class"></i></label>
Run Code Online (Sandbox Code Playgroud)
我有两个独立的jQuery监听器:
$(document).on("click", ".title-label", function (e) { //magic happens here
Run Code Online (Sandbox Code Playgroud)
另一个:
$(document).on("click", ".del-class", function (e) { //the whole label gets deleted
Run Code Online (Sandbox Code Playgroud)
当我点击标签时,我向.ajax服务器发送请求并发生魔术.还有一个i用于删除整个标签的小图标也可以使用.但是,当我点击.del-class图标时,它首先触发.title-label将请求发送到服务器的点击,发生魔术,然后标签被删除.图标需要保留在标签内,但是当我点击它时,它不应该触发标签上的点击和魔术,而是立即删除标签.
我试过各种尝试包括这样的:not选择器:
:not('.del-class') .title-label
Run Code Online (Sandbox Code Playgroud)
但两者总是被触发.任何线索在这种情况下正确的选择器是什么?
目前我收到这种消息,我不知道如何解决。
该命令php -m告诉我 PDO 和 pdo_mysql 在那里。
我在 Ubuntu 18.04.1 LTS 上使用 Drupal-8 和 php7.1.20
[Tue Sep 04 09:27:48.210064 2018] [php7:notice] [pid 2183] [client 10.56.99.1:53758] 错误:/var/core/www/dev/中未定义的类常量“MYSQL_ATTR_USE_BUFFERED_QUERY” Drupal/Core/Database/Driver/mysql/Connection.php on line 134 #0 /var/www/dev/web/core/lib/Drupal/Core/Database/Database.php(376): Drupal\Core\Database\ Driver\mysql\Connection::open(Array)\n#1 /var/www/dev/web/core/lib/Drupal/Core/Database/Database.php(166): Drupal\Core\Database\Database:: openConnection('default', 'default')\n#2 [内部函数]: Drupal\Core\Database\Database::getConnection('default')\n#3 /var/www/dev/web/core/lib /Drupal/Component/DependencyInjection/PhpArrayContainer.php(79): call_user_func_array('Drupal\\Core\\Dat...',Array)\n#4 /var/www/dev/web/core/lib/Drupal/Component/DependencyInjection/Container.php(171): Drupal\Component\DependencyInjection\PhpArrayContainer->createService(Array, 'database')\ n#5 /var/www/dev/web/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php(260): Drupal\Component\DependencyInjection\Container->get('database', 1)\n#6 /var/www/dev/web/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php(62): Drupal\Component\DependencyInjection\PhpArrayContainer->resolveServicesAndParameters(Array)\n#7 /var/www/dev/ web/core/lib/Drupal/Component/DependencyInjection/Container.php(171): Drupal\Component\DependencyInjection\PhpArrayContainer->createService(Array, 'cache.container')\n#8 /var/www/dev/web /core/lib/Drupal/Core/DrupalKernel.php(516):Drupal\Component\DependencyInjection\Container->get('cache.container')\n#9 /var/www/dev/web/core/lib/Drupal/Core/DrupalKernel.php(877): Drupal\Core\DrupalKernel ->getCachedContainerDefinition()\n#10 /var/www/dev/web/core/lib/Drupal/Core/DrupalKernel.php(469): Drupal\Core\DrupalKernel->initializeContainer()\n#11 /var/ www/dev/web/core/lib/Drupal/Core/DrupalKernel.php(665): Drupal\Core\DrupalKernel->boot()\n#12 /var/www/dev/web/index.php(19) : Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))\n#13 {main}Drupal\Core\DrupalKernel->initializeContainer()\n#11 /var/www/dev/web/core/lib/Drupal/Core/DrupalKernel.php(665): Drupal\Core\DrupalKernel->boot()\n #12 /var/www/dev/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))\n#13 {main}Drupal\Core\DrupalKernel->initializeContainer()\n#11 /var/www/dev/web/core/lib/Drupal/Core/DrupalKernel.php(665): Drupal\Core\DrupalKernel->boot()\n …
关于如何从您的Yii 2.0应用程序URL隐藏index.php的网上有大量信息,但是,我在这里要做的是从URL中删除'/ basic/web /'./ basic/web是运行应用程序的目录,到目前为止我的配置如下.这进入配置文件:
'urlManager' =>[
'enablePrettyUrl' => true,
'showScriptName' => false,
],
Run Code Online (Sandbox Code Playgroud)
这是我在/ web文件夹中的htaccess文件:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Run Code Online (Sandbox Code Playgroud)
到目前为止,这么好,我可以访问直接调用的东西mysite.com/basic/web/controller/action.虽然要删除/ basic/web以使URL变得简单,但我需要做什么mysite.com/controller/action?
欢迎任何提示,谢谢!
编辑:我正在寻找一种不触及apache配置文件的方法,因为我无法访问它.