0

iam working on iOS project and there is a statistics page is already done with JS and when loading it into UIWebView everything works fine with a nice Animation

[WebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]];

and the JS code is executed in document.Ready when the DOM is ready..

 $(document).ready(function () { 
var s1 = [[2002, 112000], [2003, 122000], [2004, 104000], [2005, 99000] ];
});

My problem is the data is generated in IOS and i want to pass this data to the JS to draw the chart with a nice animation,,i didn't find a way to pass a parameter to document.Ready so i make this a function and in IOS call this function and pass the parameters... so i changed my code to ..

-(void)webViewDidFinishLoad:(UIWebView *)webView
{ 
 NSString * param  = @"foo";
 NSString * jsCallBack = [NSString stringWithFormat:@"myFunc('%@')",param];
 [webViewstringByEvaluatingJavaScriptFromString:jsCallBack];
 [webView stringByEvaluatingJavaScriptFromString:jsCallBack];
}

and the JS to

function myFunc (var x) { 
var s1 = [[2002, 112000], [2003, 122000], [2004, 104000], [2005, 99000] ];
};

doing that actually passing parameters BUT the animation doesn't appear anymore for reason i don't know and i have tried this with lots of online ready jS charts when i change the function from document.Ready to another function gets called by IOS they appear but don't animate ....So is there is anyWay to pass a parameters to document.Ready ??

1 Answer 1

1

It's not easiest to send your data generated in iOS directly at the beginning? I mean, when you load your UIWebView, you can sent in parameters (POST or GET) your values.

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

1 Comment

u mean if i send values with post or Get i will be able to use them in document.REady() function ? can u please write a very very sample code so that i get what u mean ..thanks in advance.

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.