0

次のIDの下にあるオブジェクト内のオブジェクトを削除する次の関数があります:

contactDeleteCounter++;
console.log(orderContactIds);
console.log(deletePosition);
console.log(orderContactIds[deletePosition]);
delete orderContactIds.deletePosition;
console.log(orderContactIds.deletePosition);
console.log(orderContactIds);
console.log(deletePosition);

問題は、Chrome ではすべてが正常に機能することですが、Firefox の Firebug では次の出力が表示されます。

Object { 0={...}, 1={...}, 2={...}}
2
Object { id= "20" , type= "1" }

undefined
Object { 0={...}, 1={...}, 2={...}}
2

ご覧のとおり、属性は未定義ですが、オブジェクトを調べると、まだそこにあります...?

4

2 に答える 2

1

答えは、コールバックを作成し、非同期 Jquery を作成することです。

function deleteCallback(deletePosition) {
    $.ajaxSetup({
        async : false
    });
    console.log(orderContactIds);
    console.log(deletePosition);
    console.log(orderContactIds[deletePosition]);
    delete orderContactIds[deletePosition];
    console.log(orderContactIds.deletePosition);
    console.log(orderContactIds);
    console.log(deletePosition);
    $.ajaxSetup({
        async : true
    });
}
于 2013-04-19T10:36:28.147 に答える