Jason
Jason

Reputation: 11

jQuery progressbar with ajax request to json

I need some help with an ajax request and the use of data in a jQuery progressbar.

Here is the index.html

<div id="progressbar"></div>

Here is the test.json

{ "progressbar":12 }

Here is the JavaScript code

$(function() {

    $.ajax({ dataType:"json",
        url: test.json, 
        success: <!-- dont know what to do here -->,
    });

    $( "#progressbar" ).progressbar({
        value: <!-- Dont know what to do here  -->  
    });
});

I am sorry, but I am not used to jQuery and json. I would be glad for a really good example!!!

Thank you very much!

Upvotes: 0

Views: 4439

Answers (1)

Quannt
Quannt

Reputation: 2075

Use your success to update the progress bar

$(function() {
    $.ajax({ dataType:"json",
        url: "https://gist.githubusercontent.com/quannt/d60905a978058de2312b/raw/2d4ab1df422dc19b7214d10ffd5e80795e2aa0a5/gistfile1.txt", 
            success: function(data){
                $( "#progressbar" ).progressbar({
                    value: data.progressbar
                });
            }
    });
});

Fiddle here

Upvotes: 2

Related Questions