javascript - Update every second to determine whether a new array appears in the updated json object
某草草
某草草 2017-06-12 09:31:37
0
2
730

This is what I think, create a global variable first, and compare it with the global variable every time you get a new json object to determine whether there is a new array or part of the value has changed

var Lastdata = 
[{"Account_Instrument": "8030800200", "Avaliable_Volume": 215090.06, "Reference": 227715.86}]

get alarmdata //简写一下

data = [{"Account_Instrument":"8030800200","Avaliable_Volume": 215090.06, "Reference": 227715.86},{"Account_Instrument": "8030800210", "Avaliable_Volume": 215090.06, "Reference": 227715.86}]

function Repeat(obj1,obj2){
    for(var key in obj1){
        if(obj1[key] != obj2[key]){
            notify
        }
    }
    data = Lastdata;    
}
Repeat(Lastdata,data);

Not yet practiced
As shown in the codeLastdata is a global variable, followed by data is the updated data, and then judgment is made, and then the new data is stored in Lastdata Here, this cycle

Please let me know if this is possible or if there is a better way (need to make an early warning system)

Question supplement:
http://hqxjq.com.board.segmen...
I saw some ideas from this. In my case, I compare a and b
and then judge b (That is, the latter object) Is there a key that is not in a? If so, this warning will be triggered

某草草
某草草

reply all(2)
習慣沉默

Use websocket to achieve real-time push. If there is an update on the server, it will be pushed directly to the front desk without polling. There is dwmo here, https://github.com/treeandgra... For enterprise-level applications, you can use socket.io, which is easier to use.

洪涛

You can try hashing.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template