小编Shi*_*hel的帖子

如何处理ajax 201

在进行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)

javascript jquery

11
推荐指数
3
解决办法
7687
查看次数

Ember 测试失败,并显示“testem.js 未加载?”

当我在本地运行测试时,我收到了下面提到的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)

javascript phantomjs ember.js ember-qunit

6
推荐指数
1
解决办法
3029
查看次数

navigator.permissions.query Permissions API是否有替代方法?

是否有任何替代navigator.permissions.query 权限API查询,以检查geolocation许可。导致其仍在工作草案中,并且浏览器兼容性较差。

W3C权限参考: https : //www.w3.org/TR/permissions/

问题是,app resume一旦用户对本机权限弹出窗口执行操作,然后要检查action用户是否采取了该措施。

混合式Cordova应用回调,用于位置权限警报

平台:移动Android

注意:不想使用cordova diagnostic plugin

例:

navigator.permissions.query({name:'geolocation'}).then(function(result) {

  console.log('result : ', result);

});
Run Code Online (Sandbox Code Playgroud)

html javascript google-maps-api-3 w3c-geolocation cordova

6
推荐指数
2
解决办法
1815
查看次数

FirebaseError:消息传递:我们无法注册默认服务工作者

您好,请帮帮我....感谢您的回复.................................通知许可的确。; 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)

jquery firebase firebase-cloud-messaging

5
推荐指数
1
解决办法
1万
查看次数

使用 firebase 7.14.6 和 @angular/fire 6.0.0 FCM Web 推送通知的“AngularFireMessaging”类型上不存在属性“消息”

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)

angularjs firebase firebase-cloud-messaging angularfire2

5
推荐指数
2
解决办法
5393
查看次数

RegEx 用于电子邮件验证,其中 @ 之前至少需要 2 个字符

我正在尝试下面的 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})$

javascript regex

1
推荐指数
1
解决办法
81
查看次数

在angularfire中有一种方法可以查询匹配的AND条件

我们如何从angularfire查询firebase以匹配两个条件.我想在以下两个条件下搜索AND匹配

  1. 如果你的钥匙有红色
  2. 如果你的密钥有一个类别十六进制

或者什么是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" ]
        } …

firebase angularfire

0
推荐指数
1
解决办法
1000
查看次数