Online Manual for GSII (GA-6221)
Category: Liquid thermometersQ:
Check the value of a JSON object for existence
I've been asked to build a bit of code to verify the existence of a value in a JSON file, for example, if the value exists, then write out the code.
Here's what I've been asked to do.
Get a list of codes from the same file.
Check if any of the codes exist.
If no codes exist, don't write anything.
If a code exists, get the value of the code and write that to the file.
The file can be of any format - CSV, Excel, JSON etc.
I've come up with the following but it's not working.
$(document).ready(function() {
$.getJSON("data.json", function(data){
if (data.code!== null) {
$.each(data.code, function(key, value) {
var code = value;
var path = '';
$.ajax({
type: "GET",
url: path,
dataType: "json",
data: {
"c": code
},
async: false,
success: function(data){
console.log(data);
}
});
});
} else {
console.log("No codes found");
}
});
});
This works, it's just not returning anything. I suspect this is because the file I'm pulling the data from is an excel spreadsheet, and I need to read the data differently. I think my problem is the dataType. Any help would be be359ba680
Related links:
Comentarios