IPhone UIWebView stringFromJavaScript with jQuery

I am looking for a way to include jQuery javascript library in my project so that I can use

[myWebView stringByEvaluatingJavaScriptFromString:a jquery command];

This does not work:

NSString *jQueryPath = [[NSBundle mainBundle]pathForResource:@"jquery-1.4.1" ofType:@"js"];
NSData *jQueryData = [[NSData alloc] initWithContentsOfFile:jQueryPath];
jQuery = [[NSMutableString alloc] initWithData:jQueryData encoding:NSUTF8StringEncoding];
NSString *javaScript = [jQuery stringByAppendingString:@"$('#ct100_mainContent_hypEmbGamerTag img').attr('src');"];
NSString *returnValue = [theWebView stringByEvaluatingJavaScriptFromString:javaScript];

I think this has something to do with how Objective-C handles the / character.

Any suggestions?

+3
source share
1 answer

A little late, I know, but the easiest way would be to include the jQuery library through the tag on the page, if possible.

I'm having problems with ajax calls, sometimes freezing after interacting with a user in UIWebView.

+1
source

Source: https://habr.com/ru/post/1731309/


All Articles