javascript - Knockout JS Script works in Chrome but not in IE9 -


i have web page works great in chrome not in ie9. error comes on console error

script5022: unable parse bindings. message: [object error]; bindings value: foreach: statlist.

html below:

<html>     <head>         <title>todo supply title</title>         <meta charset="utf-8">         <meta name="viewport" content="width=device-width, initial-scale=1.0">     </head>     <body>         <div id="statsarea" data-bind="foreach: statlist">            <p> typecount: <strong data-bind="text: typecount"></strong>, priority: <strong data-bind="text: sentdate"></strong>             <br/>            </p>      </div>           <script src="js/jquery-1.9.0.js" type="text/javascript"></script>         <script src="js/knockout-2.2.1.js" type="text/javascript"></script>         <script src="models/messagecount.js" type="text/javascript"></script>      </body> </html> 

javascript:

function messagecountdatamodel() {      var self = this;     var allcounts = (function() {          var json = null;          $.ajax({             'async': false,             'global': false,             'url': "http://localhost:8080/api/getstats.json",             'datatype': "json",             'success': function(data) {                 self.statlist = data;             }         });     })(); }  ko.applybindings(new messagecountdatamodel()); 

one more piece of info that json comes out of api looks this. i'm not sure if it's because typecount not string?

[     {         "typecount": 102,         "sentdate": "2014-08-18t00:00:00.000z"     } ] 

it's not idea use async: false. maybe problem because don't initialize statlist attribute in yout viewmodel. better solution make statlist observable array, make async call , when ready set data.

example:

function messagecountdatamodel() {     var self = this;      self.statlist = ko.observablearray();      self.loaddata = function() {         $.ajax({             'url': "http://localhost:8080/api/getstats.json",             'datatype': "json",             'success': function(data) {                 self.statlist(data);             }         });     };      self.loaddata(); }  ko.applybindings(new messagecountdatamodel()); 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -