小编vai*_*hav的帖子

Angular JS:未捕获DOMException:无法在HTMLScriptElement.callback上的'Node'上执行'removeChild'

我正在使用Angular JSON Http调用.同样当我发布这样的帖子请求时:

app.service('AjaxService', [ '$http','$q','$sce', function($http,$q,$sce) {
    return {
        getSearchResultsJSONP : function() {
            var url="http://stage-sp1004e4db.guided.lon5.atomz.com/?searchType=globalsearch&q=this&sp_staged=1&callback=JSON_CALLBACK";
            $sce.trustAsResourceUrl(url);
            $http.jsonp(url)
                .success(function(data) {
                console.log("Data for default SNP call" ,data);
            }).
            error(function (data) {
                console.log("request Failed ! ");
            });
        },
        getSearchResult : function(searchText,url){
            var defer = $q.defer();
            $http({
                url: url, 
                method: "GET",
                params: {searchresInput: searchText}
            }).then(function(data, status, header, config){
                defer.resolve(data);

            }).then(function(data, status, header, config){
                defer.reject(data);

            });
            return defer.promise;
        }
    };

}]);  
Run Code Online (Sandbox Code Playgroud)

我可以看到网络中的数据和响应是200 OK状态.

但是在完整的代码运行期间我收到错误:

Uncaught TypeError: Cannot read property 'parentElement' of undefined
    at checklistFunc …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-directive angularjs-scope

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

如何在div的两边使边距保持不变

我试图制作一个独立于浏览器的代码,里面有一个搜索栏(这个搜索栏是我从demos.jQuery.com上获得的)但是现在当我试图修复左边和右边的边距百分比时(我想要它的中心)甚至当浏览器宽度改变时对齐)我无法做到这一点,我是CSS新手可以有人帮忙吗?

我到现在为止的代码是:

HTML:

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<meta name="viewport" content="initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<title>Screen1</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<link rel="stylesheet" type="text/css" href="screen1.css">
</head>
<body>
<div id="header"><p class="p1"><b>Composite<img class="img1" src="https://cdn2.iconfinder.com/data/icons/picol-vector/32/arrow_sans_down-128.png" alt="alternate"></b></p></div>

<div id=""main>
 <div data-role="main" id="main" class="ui-content">
    <form>
      <input data-type="search" id="divOfPs-input">
    </form>
    <div class="elements" data-filter="true" data-input="#divOfPs-input">
      <p><strong>These</strong> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam</p>
      <p><strong>p elements</strong> nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam</p>
      <p><strong>are</strong> et ea rebum. Stet clita kasd …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

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

JSON-Simple导致编译器警告"类型安全:方法put(Object,Object)属于原始类型HashMap."

我刚刚遇到需要将数据放入JSONObject的情况,而这样做我收到了编译器的警告.

类型安全:方法put(Object,Object)属于原始类型HashMap.应该参数化对泛型类型HashMap的引用.

我试图参数化JSONObject但它给了我错误.

我正在使用以下代码,其中option是Object.

JSONObject additionalDetails = new JSONObject();
additionalDetails.put("showOppo", option.isShowOppo());
additionalDetails.put("showCont", option.isShowCont());
additionalDetails.put("contActionTaken", option.isConActionTaken());
additionalDetails.put("oppoActionTaken", option.isOppoActionTaken());
Run Code Online (Sandbox Code Playgroud)

这是怎么造成的,我该如何解决?

java generics parameterized compiler-warnings json-simple

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

在字符串结尾的第3个字符之前添加空格

我正在使用Angular JS,我正在为英国邮政编码进行验证.问题是有一个特定的要求,即英国邮政编码中应该有一个空格,只能通过计算最后一个字符来识别.因为在第三个最后一个字符之前应该有一个空格它应该是这样的:

A12 3AD
A123 3AD
A2 2AD

为此,我有两个主要问题:

  1. 如何操纵输入值来诱导空间.

  2. 如何实际更改字符串以添加空间

我是新手,javascript/angular有人可以告诉我该怎么做吗?

PS:我没有在项目中使用jQuery.

javascript angularjs

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

如何在 JEST 中的 express 中间件中测试 next()

经过很多努力,我无法弄清楚这一点,因此计划寻求帮助。我在我的 node+ express 应用程序中使用了一个中间件,它看起来像:

import mainConfig from '../mainConfig/index';
const axios = require('axios');

module.exports = {
    authHandler: (req, res, next) => {
        return mainConfig.initialize().then(() => {
            const apiUri = mainConfig.get('app.api');
            if (apiUri) {
                return axios.get(apiUri).then(response => {
                    next();
                }).catch(error => {
                    res.redirect('/expired');
                    throw new Error(error);
                });
            }
        }).catch(() => {
        });
    }
};
Run Code Online (Sandbox Code Playgroud)

为此,我编写了能够模拟 axios 和 mainCongig 模块的测试用例。现在,我想测试是否next()在为 axios 解析请求时被调用。有人可以帮助我吗?

我写的测试用例是:

import mainConfig from '../mainConfig';
const axios = require('axios');

const middlewares = require('./check-auth');
jest.mock('axios');

describe('Check-Auth Token', () => { …
Run Code Online (Sandbox Code Playgroud)

unit-testing node.js express jestjs

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

插入数据库时​​出错:ERROR:语法错误在"$ 1"或附近

我在java中使用查询在postgresql DB中插入.

当我手动追加参数时,我正在使用的查询工作正常,但是当我通过预准备语句给出参数时,它给出的错误为:

错误:语法错误在"$ 1"或附近

我使用以下代码:

String InsertInTi="INSERT INTO ssr_timeline_test("
                    +"ti_id, module_id, module_name, updated_date, tie_updates," 
                    +"additional_options, co_count, ca_type)"
                    +"(?,?,?,current_timestamp,?,?,?,?)";

            pres = con.prepareStatement(InsertInTi);
            pres.setInt(1,tId);
            pres.setString(2,moduleId);
            pres.setString(3,moduleName);
            pres.setString(4,ti.toJSONString());
            pres.setString(5,additionalOption.toJSONString());
            pres.setInt(6,coCount);
            pres.setString(7,caType);
            System.out.println("Query : "+pres );
            pres.execute();
Run Code Online (Sandbox Code Playgroud)

任何人都可以提出相同的解决方案吗?

我还检查了传递给参数的值的类型.这些是:

TimInsert(int tId , String moduleId, String moduleName , JSONObject ti, JSONObject additionalOption , int coCount , String caType)
Run Code Online (Sandbox Code Playgroud)

java postgresql jdbc prepared-statement java-6

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