I am using $.post() to get ajax data from the server.
$.post({
type: 'POST',
url: 'http://<ip-address>/app/path/example.htm',
data: {<proper data getting sent>},
dataType: 'json',
encode: true
})
.done(function(data){
console.log(data);
---- Do Stuff ----
})
Now in the inspector in Chrome I can see the json being returned from example.htm. There is a value in each record that is 0. There is 60 records getting returned and 1 record has Overdue: 1 and all the other records have Overdue: 0. When I check the console to see the log dump every record has overdue of 1. Every single other value in the record is untouched, but Overdue is getting changed from 0 to 1 between the server sending a 0 and the .done() console.log showing a 1.
Why is it getting changed to a 1, it should stay a 0? is there something I'm missing?
[EDIT] 1. The Do stuff part is processing the data object, and would have no effect on the data object.
The server side code at the url given in the $.post returns a serialized JSON struct and looks like this
{"list":[ {"ID":26,"CREATEDON":"2018-12-31 13:22:34.233 -06:00","FIRST_NAME":"shawn","LAST_NAME":"Smith","OVERDUE":1,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":27,"CREATEDON":"2018-12-31 13:22:58.810 -06:00","FIRST_NAME":"john","LAST_NAME":"Jones","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":28,"CREATEDON":"2018-12-31 13:43:04.793 -06:00","FIRST_NAME":"paul","LAST_NAME":"Doe","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":59,"CREATEDON":"2019-01-05 11:36:17.887 -06:00","FIRST_NAME":"David","LAST_NAME":"Smith","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":60,"CREATEDON":"2019-01-05 11:37:52.873 -06:00","FIRST_NAME":"fred","LAST_NAME":"Jones","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":65,"CREATEDON":"2019-01-05 11:50:26.360 -06:00","FIRST_NAME":"harry","LAST_NAME":"Doe","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":66,"CREATEDON":"2019-01-07 09:26:22.617 -06:00","FIRST_NAME":"rick","LAST_NAME":"James","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":70,"CREATEDON":"2019-01-10 09:15:51.707 -06:00","FIRST_NAME":"Jane","LAST_NAME":"Smith","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":71,"CREATEDON":"2019-01-10 09:18:39.630 -06:00","FIRST_NAME":"Jill","LAST_NAME":"Smith","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":72,"CREATEDON":"2019-01-10 09:26:01.330 -06:00","FIRST_NAME":"Betty","LAST_NAME":"White","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":73,"CREATEDON":"2019-01-10 09:28:16.757 -06:00","FIRST_NAME":"Sue","LAST_NAME":"white","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":74,"CREATEDON":"2019-01-10 09:28:35.617 -06:00","FIRST_NAME":"Sally","LAST_NAME":"blue","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":75,"CREATEDON":"2019-01-10 09:43:06.843 -06:00","FIRST_NAME":"Megan","LAST_NAME":"smith","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}, {"ID":76,"CREATEDON":"2019-01-10 09:51:21.650 -06:00","FIRST_NAME":"Lillian","LAST_NAME":"test","OVERDUE":0,"UTCDATETIME":"February, 07 2019 23:32:39"}],"errors":{}}
You can see that only 1 record has OVERDUE:1 Now the console.log(data) should dump this data, but somewhere along the line it is changing to a 1 for all records. As seen here in the console log dump.
leadslist: Array(61)
0:
CREATEDON: "2018-12-31 13:22:34.233 -06:00"
FIRST_NAME: "shawn"
LAST_NAME: "Smith"
ID: 26
OVERDUE: 1
UTCDATETIME: "February, 07 2019 23:32:39"
__proto__: Object
1:
CREATEDON: "2018-12-31 13:22:58.810 -06:00"
FIRST_NAME: "john"
LAST_NAME: "Jones"
ID: 27
OVERDUE: 1
UTCDATETIME: "February, 07 2019 23:32:39"
__proto__: Object
2:
CREATEDON: "2018-12-31 13:43:04.793 -06:00"
FIRST_NAME: "paul"
LAST_NAME: "Doe"
ID: 28
OVERDUE: 1
UTCDATETIME: "February, 07 2019 23:32:39"
__proto__: Object
3:
CREATEDON: "2019-01-05 11:36:17.887 -06:00"
FIRST_NAME: "David"
LAST_NAME: "Smith"
ID: 59
OVERDUE: 1
UTCDATETIME: "February, 07 2019 23:32:39"
__proto__: Object
My question is why isn't the 0 getting carried through, I might not be asking the question correctly, but it doesn't make any sense to me at all. Every value is getting brought through but the zero in OVERDUE is not. The Do Stuff part takes this data and builds a table that is displayed on screen, no further processing happens to the data. But besides, I have the code set up exactly as shown above. If there was processing with in the do stuff, it wouldn't show in the console.log this is javascript it couldn't do processing after the console dump and have that show up in the dump.