Jquery Ajax binding MultiSelect Multi-select drop-down OPTION while asynchronously executing get return value
1 functionLoad (Mslt_employees,belongto,mark) {//Incoming $ (#ID)2 varJsondata =json.stringify ({belongto:1, username:username});3 varEMP =NULL;4 Jquery.ajax ({5Type: ' POST ',6URL: ".. /tools/employees_ajax.ashx?action= "+ Action +" ",7DataType: "JSON",//Return JSON object8 Data:jsondata,//Upload parameters in JSON format9Cachefalse,TenAsyncfalse,//Asynchronous execution OneSuccessfunction(message) { A mslt_employees.empty ();//emptying the drop-down label - if(Message! = "0" && message! = "None") { - varList =message; the for(vari = 0; i < list.length; i++) { - if(Mark = = 1) { - if(Belongto! = 1) {//Set default options -Mslt_employees.append ($ ("<option value= '" + list[i]. USERNAME + "' disabled = ' disabled ' >" + list[i]. USERNAME + "</option>")); +}Else { -Mslt_employees.append ($ ("<option value= '" + list[i]. USERNAME + ">" + list[i]. USERNAME + "</option>")); + } A}Else { atMslt_employees.append ($ ("<option value= '" + list[i]. USERNAME + ">" + list[i]. USERNAME + "</option>")); - } - if(i = = 0) {emp = List[i]. USERNAME; }Else { -EMP = emp + "," +List[i]. USERNAME; - } - } in } -Mslt_employees.multiselect (' Refresh ');//Refresh Multi-Select drop-down label to}, Error:function() {return NULL; } + }); - returnemp;//return value the}
Original source: http://www.cnblogs.com/OnlyDreams/p/4143515.html
Reprint please keep this link
Jquery Ajax binding MultiSelect Multi-select drop-down OPTION while executing the return value asynchronously