can anyone help... I want to populate my dropdown box on my html page with data from the database but I keep getting this error:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
but when I inspect elements with chrome the array is filled with data but my dropdown box is not populated..... here is my script:
$(document).ready(function() {
function supplier(data) {
var self = this;
self.id = ko.observable(data.supplierNo);
self.name = ko.observable(data.name);
}
function supplierViewModel() {
var self = this;
self.suppliers = ko.observableArray([]);
$.ajax({
type: "GET",
url: "http://localhost:8080/SupplyChainMan/rest/Suppliers/getSuppliers",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
var mappedData= $.map(allData, function(data) { return new supplier(data) });
self.suppliers(mappedData);
console.log(self.suppliers());
},
error: function() {
alert("Failed to load Supplier");
}
});
}
ko.applyBindings(new supplierViewModel());
});
...... my html is simple like this:
<table>
<tr>
<th>
Supplier Name
</th>
<td>
<select data-bind='options: suppliers, optionsText: "name"'></select>
</td>
</tr>
</table>