0

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>
Hans Roerdinkholder
  • 3,000
  • 1
  • 20
  • 30
Aph1ka
  • 368
  • 1
  • 4
  • 17
  • Please use the search function next time... http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource http://stackoverflow.com/questions/20433655/no-access-control-allow-origin-header-is-present-on-the-requested-resource-or – Hans Roerdinkholder Aug 19 '14 at 10:08
  • 1
    Variable `allData` is `undefined`. Use `data` instead – Ilya Aug 19 '14 at 10:17

0 Answers0