3

I'm looking for a way to include the jQuery javascript library in my project so I can use

[myWebView stringByEvaluatingJavaScriptFromString:a jquery command];

This doesn't 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 it has something to do with the way Objective-C handles the / character.

Any suggestions?

1 Answer 1

1

A bit late coming I know, but the easiest way would be to include the jQuery library via a tag on the page if possible.

I'm having problems with the ajax calls screwing up sometimes after user interactions on the UIWebView though.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer. What page are you referring to? I was wanting to apply a JQuery to a webpage that I didn't have control of editing. Like "Download page from XYZ Server, apply this JQuery logic to it."

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.