Skip to content Skip to sidebar Skip to footer

Get Json Data From Another Page Via Javascript

I have a page where I want to add couple of controls when I click on 1st control, I want my javascript to open particular JSONpage, gram the content and then output the content in

Solution 1:

Got this working

function getDates() {
    jQuery(function($) {                   
        $.ajax( {   
            url : "jsonPage.php",
            type : "GET",
            success : function(data) {
                // get the data string and convert it to a JSON object.
                var jsonData = JSON.parse(data);
                var date = new Array();                                
                var i = -1;                               
                $.each(jsonData, function(Idx, Value) {
                    $.each(Value, function(x, y) {
                        if(x == 'date')
                        {
                            i = i + 1;
                            date[i] = y;
                        }                                                
                    });
                });
                //output my dates; [0] in this case         
                $("#testArea").html(date[0]);
            }
        });
    });
}

Post a Comment for "Get Json Data From Another Page Via Javascript"