1

I'm trying to display piechart in UIWebview of my iOS xcode project, for that I'm using jqplot with HTML, CSS and JavaScript, the issue I face is JavaScript file "devicepiechart.js" is loading from the html.

<!DOCTYPE html>

<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="jquery.jqplot.css" />
<script>
            function load()
            {
                alert("I am an loading scripts!");
            }
        </script>

<script src="devicepiechart.js"></script>
</head>
<body onload= "load()">
</body>
</html>

The load() function alert is shown properly without any problem. I could detect that my .js file is not loading as I have the alert("string"); function in my .js file too for debugging.

UPDATED devicepiechart.js, and I hope the external .js file may not have any error, because I have the source from this http://www.jqplot.com/tests/pie-donut-charts.php

$(document).ready(function()
      {
              alert("good");
              var data = [
                          ['Heavy Industry', 12],['Retail', 9], ['Light Industry', 14],
                          ['Out of home', 16],['Commuting', 7], ['Orientation', 9]
                          ];
              var plot1 = jQuery.jqplot ('chart1', [data],
                                         {
                                         seriesDefaults: {
                                         // Make this a pie chart.
                                         renderer: jQuery.jqplot.PieRenderer,
                                         rendererOptions: {
                                         // Put data labels on the pie slices.
                                         // By default, labels show the percentage of the slice.
                                         showDataLabels: true
                                         }
                                         }, 
                                         legend: { show:true, location: 'e' }
                                         }
                                         );
              });
4
  • 1
    If loading inline scripts works but loading script files doesn't, that pretty firmly points to a problem loading the file. (Or, of course, there's a serious error in the external script -- which you haven't shown -- preventing it from being parsed successfully.) Commented Dec 4, 2013 at 7:59
  • 1
    Side note: Neither language nor type is necessary. language has been deprecated for well more than a decade. type's default is and always has been text/javascript. So... Commented Dec 4, 2013 at 7:59
  • @T.J. Crowder, As u said I have deleted the language and type from my html, even then the same result and I have updated my question by including the javascript file, please refer to it. Commented Dec 4, 2013 at 8:10
  • @T.J.Crowder, while opening my html file in browser, all the alerts are displaying as expected but in xcode ios its not loading, what should be changed for clearing that issue. Commented Dec 4, 2013 at 10:08

2 Answers 2

1

Include jquery before the other js loads

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
Sign up to request clarification or add additional context in comments.

3 Comments

@sathya: It was definitely missing (though why runelynx pointed you at such an out of date version is unclear). Perhaps you added it in the wrong place. It goes before the tag loading your file.
and yes, be sure to put it before all other javascript <scripts> :)
@runelynx, ya I used before javascripts.Then too the alert in js file is not working. And I was trying to include the devicepiechart.js file in the html file within the <script> tag, then the alert function is working.
0

Just load all your .js files into "copy bundle resources" of project Targets "bulid phases" , now the piechart is running successfully in ios simulator.

1 Comment

Please elaborate on this. I don't get 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.