jQuery autopopulate select drop down from JSON issues

Posted by Jonathon Joyce on Stack Overflow See other posts from Stack Overflow or by Jonathon Joyce
Published on 2010-04-19T12:28:00Z Indexed on 2010/04/19 13:33 UTC
Read the original article Hit count: 526

Filed under:
|
|
|
|

I have an issue regarding to auto populating a select dropdown from jQuery/JSON data which is return from a ColdFusion CFC, the code is below:

$(function(){
$("#licences-add").dialog({autoOpen:false,modal:true,title:'Add Licences',height:250,width:380});

});

function openAddLicence(intInstanceID,szName,szDatasourceName){
$.getJSON('/ASPAdmin/billing/handler.cfc?method=ListLicenceTypes&queryformat=column',{szInstanceDatasource:szDatasourceName}, 
    function(data){   
        $.each(data,function(){
            $('<option></option>').val(data.DATA.UUIDLICENCETYPE).text(data.DATA.SZLICENCETYPE).appendTo('#uuidLicenceType');
        });
    });
$("#intInstanceID").attr('value', intInstanceID);
$('span#szInstanceName').text(szName);
$("#licences-add").dialog('open');};

The json returned is:

{"ROWCOUNT":1,"COLUMNS":["UUIDLICENCETYPE","SZLICENCETYPE"],"DATA":{"UUIDLICENCETYPE":["480CE560-BCD3-C7AC-AF50B3C71BBCC473"],"SZLICENCETYPE":["Standard"]}}

However i get the following error:

$("").val(this.UUIDLICENCETYPE).text is not a function

Any ideas?

HTML:

<tr>
<td><label for="uuidLicenceType" title="Select the licence type (required).">Licence Type</label> <span class="req">*</span></td>
<td>
    <select name="uuidLicenceType" id="uuidLicenceType" class="bmSelect">
        <option value=""></option>
    </select>
</td>
</tr>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JSON