I am trying to use a plugin for a dropdown which takes in JSON data for options values for the selects.
http://designwithpc.com/Plugins/ddSlick
$('#myDropdown').ddslick({
data:ddData,
width:300,
selectText: "Select your preferred social network",
imagePosition:"right",
onSelected: function(selectedData){
//callback function: do something with selectedData;
}
});
Here ddData is the JSON variable that has the data for the dropdown. I am trying pulling the data from server using jQuery.getJSON(), I am having two problem.
- How do I cache the data?
- How do I get the jsondata from server and directly feed into this function above?
From looking at examples of jQuery.getJSON() it does a callback to use data inside. So I am not sure how to get pass the result directly.
I was looking for something like below, but its not working.
$('#myDropdown').ddslick({
data:$.getJSON('ajax/test.json'),
width:300,
selectText: "Select your preferred social network",
imagePosition:"right",
onSelected: function(selectedData){
//callback function: do something with selectedData;
}
});
If you want to pass the data object to the ddslick argument object you have to work in the
getJSONcallback function as you can seen the jQuery doc API