passing variable ..
passing variable ..
hi i have a problem when i try to pass variable in javascript or maybe this is jquery matter
i'm using tokenize plugin from this site :
http://loopj.com/2009/04/25/jquery-plugin-tokenizing-autocomplete-text-entry/
problems comes when i about to set a predefined value for the token, if i use static variable like this script its working ok
- $("#tokenize2").tokenInput("http://localhost/ci/index.php/skripsi/adminPanel/listPeserta/", {
- prePopulate: [{ "id":"1","name":"Populated Name 1" },{ "id":"2","name":"Populated Name 2" }],
- hintText: "Ketik nama untuk menambahkan",
- noResultsText: "Tidak ada data",
- searchingText: "Sedang mencari..."
- });
and my goal is to change prePopulate to a dynamic variable, so i try use this code :
- $.ajax({
- type:"POST",
- url:"http://localhost/ci/index.php/skripsi/adminPanel/pesertaUndangan/",
- data: info2,
- dataType: 'json',
- success:function(data){
- var resultPopulate = data;
- }
- });
- $("#tokenize2").tokenInput("http://localhost/ci/index.php/skripsi/adminPanel/listPeserta/", {
- prePopulate: resultPopulate,
- hintText: "Ketik nama untuk menambahkan",
- noResultsText: "Tidak ada data",
- searchingText: "Sedang mencari..."
- });
but this script result is "resultPopulate undefined" is there any idea about this ?