javascript - How to use getJSON with this code -
I have found this select box which uses JSON data to populate the option. . The data is hard, but I want to load the data using the I found the drop down box Original code: This is my failed attempt: Suggest.JSON: According to your code, simply swap the plugin call : $ .getJSON () method, but I can not find the right code. I think the suggest.json file has started, but There is some other problem happening. Will someone show me to fix this problem?
& lt; Script type = "text / javascript" & gt; $ .getJSON ('suggest.json', function (data) select {var $ = $ ('# mySelectID'); $ .eee (data, function (index, o) {var $ option = $ (" Lt; option />").attr("value ", o.CODE) .text (o.box1 +" | "+ o.id); $ select.append ($ option);})}}); JQuery ("# mySelectID") dynamicDropdown ({"delimiter": "|"}} & Lt; / Script & gt;
[{"box 1": "Africa", "code": 1, "id": "A"} , "Code": 3, "id": "c": {"box 1": "Asia", "code": 2, "id": "b"}, {"box 1": "south america", "code" The problem is that you get the value of
$ ("# mySelectID");
$ (document) .ready (function () {$ .getJSON ('my.json', function) {var $ select = $ ('# mySelectID'); $.eitch (data, function (index, o) {var $ option = $ ("& lt; option />"). Attr ("value", o.code) .text (obox1 + "| "OAID"); $ APPEND ($ option);}); $ ("# mySelectID"). Dynamic DROPDOWN ({"" "Delimiter": "|"});});}); By the way, you have an error with your Jason: the last item ("South America") is "code" and according to others the code "note"
Comments
Post a Comment