小编Syl*_*Syl的帖子

jQuery,ajax请求在IE上使用JSON没有成功

我做了一个AJAX调用,它适用于FF和Chrome,但不适用于IE 7-8-9.我正在从我的域中加载JSON文件:

    $.ajax({
        url: 'js/jquery.desobbcode.json',
        dataType: 'json',
        cache: false,
        success: function(json) {
            alert('ok');
        },
        error: function(xhr, errorString, exception) {
            alert("xhr.status="+xhr.status+" error="+errorString+" exception="+exception);
        }
    });
Run Code Online (Sandbox Code Playgroud)

我也尝试添加,contentType: 'application/json'但我收到相同的输出,这是:

xhr.status=200
error=parsererror
exception=SyntaxError Unterminated string constant
Run Code Online (Sandbox Code Playgroud)

我用JSONLint检查了我的JSON文件,没关系.我检查是否有额外的逗号,内容也被修剪.请参阅我的JSON文件

如果我放dataType: 'text',我收到OK警报,但也有一个调试弹出窗口.

你可以帮帮我吗?问候.

ajax jquery internet-explorer json

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

与Stapes.js的继承

我正在尝试使用JS框架Stapes.js建立父/子链接.

这是我的代码:

var Parent = Stapes.subclass({
    constructor: function () {
        this.name = 'syl';
    }
});

var Child = Parent.subclass({
    constructor: function (value) {
        this.value = value;

        console.log(this.name); // undefined
    }
});

var child = new Child('a value');
Run Code Online (Sandbox Code Playgroud)

小提琴这里.

如何从子类访问父级的name属性?

javascript inheritance stapes.js

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

Chrome扩展程序:从后台页面的DOM弹出页面中注入HTML

我现在卡在后台页面中,我想在background.html的popup.html DOM上使用.html()jQuery方法.

我发现了一些东西

var x = chrome.extension.getViews({type:"popup"});
Run Code Online (Sandbox Code Playgroud)

我和x有什么关系?

弹出窗口可能会关闭.

google-chrome-extension

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

Angularjs:ng-repeat with clone功能

我有一个对象数组,我可以克隆一个"行"(对象)来填充数组.它可以工作但是当我修改任何值时,数组的所有对象都会更新.

TL; DR:克隆的行必须具有独立的值

<ul>
    <li ng-repeat="comment in comments track by $index">
        <input type="text" ng-model="comment.text">

        <button type="button" ng-click="cloneRow(comment)">Clone this row</button>
    </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

JS:

$scope.comments = [
    { text: 'test' }
];

$scope.cloneRow = function(comment){
    $scope.comments.push(comment);
};
Run Code Online (Sandbox Code Playgroud)

目前的情况:

  1. 点击"克隆此行"
  2. 在克隆的输入中键入任何内容
  3. 第一个输入的值已更改

需要的案例:

  1. 点击"克隆此行"
  2. 在克隆的输入中键入任何内容
  3. 第一个输入的值没有改变
  4. 克隆输入的值已更改

这是傻瓜.

angularjs angularjs-ng-repeat

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