1

i have a problem similar to my previous question but now its different

jquery : progress bar show in html

  var auto_refresh = setInterval(
   function ()
  {
     $('#battery').load('https=://localhost/userinfo/battery_level/');

 }, 10000);

i dont want to load the div ... i want to get the result and want to display in my progress bar here

 $('.demo-progress').progress(data);

i am geting a value here "10"

want to do something like this

 var auto_refresh = setInterval(
   function ()
  {
    var data =  $('#battery').load('https=://localhost/userinfo/battery_level/');

 }, 10000);
      $('.demo-progress').progress(data);
2
  • What's in your batter_level file? Commented Aug 16, 2013 at 20:46
  • its a controller name which is sending just the value ... for example 20 Commented Aug 16, 2013 at 20:50

1 Answer 1

1

Try this:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" type="text/css" rel="Stylesheet" />
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script>
        $(function () {
            $("#progressbar").progressbar({ max: 100, value: 10 });
            $("#twenty").click(function () { loadFile("20"); });
            $("#fifty").click(function () { loadFile("55"); });
            $("#eighty").click(function () { loadFile("80"); });
        });


        function loadFile(file) {
            $.get(file + ".txt", function (data) {
                var value = parseInt(data, 10);
                $('#progressbar').progressbar("option", "value", value);
            });
        }
    </script>
</head>
<body>
    <div id="progressbar">
    </div>
    <input type="button" id="twenty" value="Load to 20%" />
    <input type="button" id="fifty" value="Load to 50%" />
    <input type="button" id="eighty" value="Load to 80%" />
</body>
</html>

From the jquery page:

This method (.load) is the simplest way to fetch data from the server. It is roughly equivalent to $.get(url, data, success) except that it is a method rather than global function and it has an implicit callback function.

The reason why I am using .get is because of the last part, the implicit callback function, which let's me know when the function has ended, and I can then update the progressbar.

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

13 Comments

i dont want to use get .. as i want to show the real time data without page refresh .. and i think by using ur code i have to refresh the page for the result
Why don't you try it first? This will not refresh the page.
oooookkk let me try it
nope not working... well i think u should give some time interval .. dont u ... as yet it is not giving me the value without refresh
are you sure you are calling .progressbar method correctly? You have it different in the other question $(".demo-progress").progressbar("option", "value", 50); so maybe its $(".demo-progress").progressbar("option", "value", data);
|

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.