1

I know this is possible in Java with Javascript handler :

   graphView.addJavascriptInterface(handler, "javahandler");
   graphView.loadUrl("file:///android_asset/html/show_data_from_file.html");

    JSONObject json = new JSONObject();
    json.put("data", jsonArray);
    json.put("label","labelString");
    handler.json = json;

Within the javascript page, the "javahandler" would have "json" object, which I can get the data array and the label to display on the page.

Is there something similar for iOS? I'm very new to web programming with iOs, and would appreciate your help!

1 Answer 1

2

You can use stringByEvaluatingJavascriptFromString to call a javascript method and pass your JSON string through that method,

[yourWebViewInstance stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"useThisJSONString(%@)", JSONString]];
Sign up to request clarification or add additional context in comments.

2 Comments

are there any limits on the string length with this method? I want to pass about 700kb of data.
I guess no, But this may reduce the performance of your javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.