I can't add new options to "select" element using jQuery -
i have mvc application , there's view javascript code. data service , return json string (not object). here'e controller code:
public jsonresult getdatatableasjson() { return json(mobileserviceclient.getallcashdesks(), jsonrequestbehavior.allowget); }
the javascript code in view:
$.ajax({ ... html.push('<select id="options">'); html.push('</select>'); $.ajax({ url: hostname + 'search/getdatatableasjson', contenttype: "application/json; charset=utf-8", datatype: "json", crossdomain: "true", async: false, success: function (data1) { var dt = json.parse(data1); $.each(dt, function(key, value) { $('#options').append($("<option></option>").attr("value", value.cityname).text(value.cityname)); ...
what happen? list empty, there should items.
when check "select" element inside second ajax call:
var menu = document.getelementbyid("options");
the menu null.
what i'm doing wrong?
Comments
Post a Comment