From a86126821f54dceb3893d68457e50a882d49b183 Mon Sep 17 00:00:00 2001 From: wangmingxing Date: Wed, 4 Jan 2017 11:58:18 +0800 Subject: [PATCH] Check the responseCallback before call it --- example/src/main/assets/demo.html | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/example/src/main/assets/demo.html b/example/src/main/assets/demo.html index c1dd3d1..dc358fc 100644 --- a/example/src/main/assets/demo.html +++ b/example/src/main/assets/demo.html @@ -94,16 +94,22 @@ var data = { 'Javascript Responds': '测试中文!' }; - console.log('JS responding with', data); - responseCallback(data); + + if (responseCallback) { + console.log('JS responding with', data); + responseCallback(data); + } }); bridge.registerHandler("functionInJs", function(data, responseCallback) { document.getElementById("show").innerHTML = ("data from Java: = " + data); - var responseData = "Javascript Says Right back aka!"; - responseCallback(responseData); + if (responseCallback) { + var responseData = "Javascript Says Right back aka!"; + responseCallback(responseData); + } }); }) - \ No newline at end of file + +