I have the code below:
var allitems = "<option value=''>Choose an item</option>";
$.getJSON("http://localhost:59886/getItems", function (data) {
var items = [];
$.each(data, function (key, value) {
if (parseInt(value.C_CODE) == parseInt($("#ccode").val())) {
allitems = allitems + "<option value='" + value.itemid+ "'>" + value.itemname + "</option>";
};
});
}, 'json').error(function (error) { console.log(error); });
When I run the code in Chrome console, I get values but when I ran it from a website, the allitems variable is empty. The JSON URL works fine.