Shoeb Siddique
Shoeb Siddique

Reputation: 2825

How to send data from WKWebview to HTML file using evaluateJavaScript | iOS | Objective-C

I need to pass certain values to my HTML from WKWebview.

Here is my code snipped of what I've tried yet.

 [self.webView evaluateJavaScript:@"document.getElementById('popo_data').innerHTML = feed,OMG,BTC;" completionHandler:^(NSString *result, NSError *error) {
         if(error != nil) {
             NSLog(@"######## SomeFunction Error: %@",error);
             return;
         }

         NSLog(@"########  SomeFunction Success");
     }];

Upvotes: 0

Views: 285

Answers (1)

Greg de J
Greg de J

Reputation: 330

That does not look like well formed JavaScript, because quotes are missing around the string you're assigning to the #popo_data element. I suppose you're getting a syntax error here.

Try the following: document.getElementById('popo_data').innerHTML = "feed,OMG,BTC"

If this does not work, you can debug your webview with Safari by connecting the debugger to your device or simulator. Safari Preferences > check "Show Develop menu in menu bar."

Upvotes: 1

Related Questions