這是從第2位開始刪除所有元素的程式
var myFish = ['angel', 'clown', 'mandarin', 'sturgeon'];
var removed = myFish.splice(2);
// 運算後的myFish :["angel", "clown"]
// 被刪除的元素數組: ["mandarin", "sturgeon"]
但現在我想做的是,利用IP找到檔案中相對應資料並刪除
[{"ID":0,"Name":"XXX","Enable":true,"IP":"XXX.XXX.XXX.01","Port":8080,"Model":"XXX"},//這是一筆
{"ID":0,"Name":"XXX","Enable":true,"IP":"XXX.XXX.XXX.02","Port":8080,"Model":"XXX"},//這是一筆
{"ID":0,"Name":"XXX","Enable":true,"IP":"XXX.XXX.XXX.03","Port":8080,"Model":"XXX"}]//這是一筆
想請問我如果用ajax的方式做(如下),
$.ajax({
url: 'test.txt',
type: 'POST',
dataType: 'text',
contentType: 'application/json; charset=utf-8',
success: function (data) {
},
error: function(jqXHR) {
}
})
因為我沒有任何跟myFish一樣的任何陣列,那麼我上面第一個程式該怎麼改?