How to retrieve sharepoint 2013 list data using JQuery or JavaScript and Fill DropDownList? -



How to retrieve sharepoint 2013 list data using JQuery or JavaScript and Fill DropDownList? -

i trying retrieve list info using javascript. goes wrong. trying debug code not able understand thing. next javascript code:

executeordelayuntilscriptloaded(populatedepartments, "sp.js"); var _ctx = null; var _web = null; var _allitems = null; function populatedepartments() { debugger; _ctx = sp.clientcontext.get_current(); _web = _ctx.get_web(); var list = _web.get_lists().getbytitle("servicetype"); var query = new sp.camlquery(); query.set_viewxml("<view><query><orderby><fieldref name='title'/></orderby></query></view>"); _allitems = list.getitems(query); _ctx.load(_allitems, 'include(title,id)'); debugger; _ctx.executequeryasync(function.createdelegate(this, this.populatedepartmentsuccess), function.createdelegate(this, this.populatedepartmentfaild)); } function populatedepartmentsuccess() { var ddlentry = this.document.getelementbyid("ddl1"); ddlentry.options.length = 0; var listenumerator = _allitems.getenumerator(); while (listenumerator.movenext()) { var currentitem = listenumerator.get_current(); ddlentry.options[ddlentry.options.length] = new option(currentitem.get_item("title"), currentitem.get_item("id")); } } function populatedepartmentfaild() { alert("something went wrong....!!"); }

whenever run code shows me alert box. please help..

there times when doesn't takes right reference.check if works removing reference .so instead of _ctx.executequeryasync(function.createdelegate(this, this.populatedepartmentsuccess), function.createdelegate(this, this.populatedepartmentfaild));

try using this

_ctx.executequeryasync(populatedepartmentsuccess,populatedepartmentfaild);

javascript jquery sharepoint visual-studio-2012 sharepoint-2013

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -