我正在使用getJSON jquery方法并且它运行了10次,这意味着它将相同的数据返回10次,从而产生重复。有谁知道我怎么能告诉它只运行一次?
谢谢!
d
// Here is what the JSON data is
{ "sampleOne" : "a cool string of text",
"sampleTwo" : "a cool string of text",
"sampleThree" : "a cool string of text",
"sampleFour" : "a cool string of text"
}
// Here is my JS, very standard
$.getJSON( "sample.js", function(data) {
$.each(data, function(key, value) {
$('<div></div>').append('<h3>' + data.sampleTwo + '</h3>').appendTo(#awesomeSelector);
});
});