try around parsing upc data
[omsmith/pos-js.git] / www / assets / js / ui.js
index 0527b58..804780d 100644 (file)
@@ -110,5 +110,14 @@ ko.applyBindings(new SelectionsViewModel());
 
 function request_upc_data (upc, callback) {
        $.ajax( 'upc.php?upc=' + upc )
-               .done(function (data) { callback(JSON.parse(data)); });
+               .done(function (data) {
+                       var obj;
+                       try {
+                               obj = JSON.parse(data);
+                       } catch (e) {
+                               obj = { name:'unknown', size:'unknown' }
+                       }
+
+                       callback(obj);
+               });
 }