在进行ajax调用时,请参阅下面的示例,success
确实会重新调整201状态.你如何更好地处理这些成功函数中的200,201?
$.ajax({
type: "POST",
dataType: "json",
url: "http://api.domain.com/sms",
data: {
// Send value in mobile input field.
mobile: $("#mobile").val(),
},
// On successful AJAX call do the following.
success: function(data) {
$('#messageText').text('SMS successfully sent');
},
error: function(jqXhr) {
data = JSON.parse(jqXhr.responseText);
}
});
Run Code Online (Sandbox Code Playgroud) 当我在本地运行测试时,我收到了下面提到的Ember 项目的ember test
错误消息。大部分时间 PhantomJS 都挂着。
$ ember test
not ok 1 Chrome - error
---
message: >
Error: Browser failed to connect within 30s. testem.js not loaded?
Stderr:
2018-07-13 11:24:43.115 Google Chrome[47537:547312] Errors logged by ksadmin: KSKeyedPersistentStore store directory does not exist. [com.google.UpdateEngine.CommonErrorDomain:501 - '/Library/Google/GoogleSoftwareUpdate/TicketStore' - 'KSKeyedPersistentStore.m:368']
KSPersistentTicketStore failed to load tickets. (productID: com.google.Chrome) [com.google.UpdateEngine.CoreErrorDomain:1051 - '/Library/Google/GoogleSoftwareUpdate/TicketStore/Keystone.ticketstore'] (KSKeyedPersistentStore store directory does not exist. - '/Library/Google/GoogleSoftwareUpdate/TicketStore' [com.google.UpdateEngine.CommonErrorDomain:501])
ksadmin cannot access the ticket store:<KSUpdateError:0x100404060
domain="com.google.UpdateEngine.CoreErrorDomain"
code=1051
userInfo={
function = …
Run Code Online (Sandbox Code Playgroud) 是否有任何替代navigator.permissions.query
权限API查询,以检查geolocation
许可。导致其仍在工作草案中,并且浏览器兼容性较差。
W3C权限参考: https : //www.w3.org/TR/permissions/
问题是,app resume
一旦用户对本机权限弹出窗口执行操作,然后要检查action
用户是否采取了该措施。
平台:移动Android
注意:不想使用cordova diagnostic plugin
例:
navigator.permissions.query({name:'geolocation'}).then(function(result) {
console.log('result : ', result);
});
Run Code Online (Sandbox Code Playgroud) 您好,请帮帮我....感谢您的回复.................................通知许可的确。; FirebaseError:消息传递:我们无法注册默认服务工作人员。无法注册 ServiceWorker:获取脚本时收到错误的 HTTP 响应代码 (404)。(消息传递/serviceworker 注册失败)。
<script src="https://www.gstatic.com/firebasejs/5.5.3/firebase-auth.js"></script>
Run Code Online (Sandbox Code Playgroud)
<script>
MsgElem = document.getElementById("msg")
TokenElem = document.getElementById("token")
NotisElem = document.getElementById("notis")
ErrElem = document.getElementById("err")
// Initialize Firebase
// TODO: Replace with your project's customized code snippet
var config = {
apiKey: "AIzaSyBle95lld9XUBB5P-sn2vFciSxcIny-RQs",
authDomain: "swapnear-f82dd.firebaseapp.com",
databaseURL: "https://swapnear-f82dd.firebaseio.com",
projectId: "swapnear-f82dd",
storageBucket: "swapnear-f82dd.appspot.com",
messagingSenderId: "390359777744"
};
firebase.initializeApp(config);
const messaging = firebase.messaging();
messaging
.requestPermission()
.then(function () {
MsgElem.innerHTML = "Notification permission granted."
console.log("Notification permission granted.");
// get the token in the form of promise
return messaging.getToken() …
Run Code Online (Sandbox Code Playgroud) 在Background Web Notification
我的服务中实施 FCM 时出现以下错误
error TS2339: Property 'messaging' does not exist on type 'AngularFireMessaging'
消息服务.ts
import { Injectable } from '@angular/core';
import { AngularFireMessaging } from '@angular/fire/messaging';
import { BehaviorSubject } from 'rxjs'
@Injectable()
export class MessagingService {
currentMessage = new BehaviorSubject(null);
constructor(private angularFireMessaging: AngularFireMessaging) {
this.angularFireMessaging.messaging.subscribe(
(_messaging) => {
_messaging.onMessage = _messaging.onMessage.bind(_messaging);
_messaging.onTokenRefresh = _messaging.onTokenRefresh.bind(_messaging);
}
)
}
}
Run Code Online (Sandbox Code Playgroud)
src/firebase-messaging-sw.js
importScripts('https://www.gstatic.com/firebasejs/7.14.6/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/7.14.6/firebase-messaging.js');
firebase.initializeApp({
apiKey: "xxxxxxxxxxx",
authDomain: "xxxxxxxxxxx",
databaseURL: "xxxxxxxxxxx",
projectId: "xxxxxxxxxxx",
storageBucket: "xxxxxxxxxxx",
messagingSenderId: "xxxxxxxxxxx",
appId: …
Run Code Online (Sandbox Code Playgroud) 我正在尝试下面的 RegEx,它在@之前至少需要2 个字符
^([a-zA-Z])[^.*-\s](?!.*[-_.@]{2})(?!.\.{2})[a-zA-Z0-9-_.]+@([\w-]+[\w]+(?:\.[a-z]{2,10}){1,2})$
喜欢
不允许:aa.@co.kk.pp
不允许:aa..@co.kk.pp
不允许:aa@co.kk.pp
应该允许:aa@co.kk.pp
应该允许:aaa@co.kk.pp
应该允许:aa.s@co.kk.pp。(特殊字符之后和@之前至少一个字符)
应该允许:aa.ss@co.kk.pp
应该允许:a@co.kk.pp
之前@
只允许. _ -
不连续的特殊字符(--)也不在开头。
我也试过下面的正则表达式,但没有运气
^[a-zA-Z)]([^.*-\s])(?!.*[-_.@]{2}).(?!.\.{2})[\w.-]+@([\w-]+[\w]+(?:\.[a-z]{2,10}){1,2})$
我们如何从angularfire查询firebase以匹配两个条件.我想在以下两个条件下搜索AND匹配
或者什么是firebase中的验证,如.indexOn或.validate
json就像
{ "color" : { "-UqPNlZ8ddgdGMFSsD" : { "color" : "red", "categories" : { "hex" : { "subcategory" : [ "#111", "#333" ] } }, "status" : "ok" }, "-U9P4pBpYiId3ID64K" : { "color" : "blue", "categories" : { "hex" : { "subcategory" : [ "#ddd", "#eee" ] } }, "status" : "ok" }, "-U9UgOdffZdfdbSydF" : { "color" : "green", "categories" : { "hex" : { "subcategory" : [ "#333", "#555" ] } …
javascript ×4
firebase ×3
jquery ×2
angularfire ×1
angularfire2 ×1
angularjs ×1
cordova ×1
ember-qunit ×1
ember.js ×1
html ×1
phantomjs ×1
regex ×1