stijn0713 Posted November 24, 2012 Share Posted November 24, 2012 (edited) I found this autoSuggest plugin that i need to make work like this: $(document).ready(function() { $(function (){ data = [ { "name": "hein frank" } ] $("#auteur").autoSuggest(data, {selectedItemProp: "name", searchObjProps: "name"}); }); }); Now i want to pass the data from this function: function suggest_auteur(inputString){ if(inputString.length != 0) { $.post("get_json/suggest_auteurs.php", {queryString: ""+inputString+""}, function(data){ alert(JSON.stringify(data, undefined, 2)); --> //[ { "name": "hein frank" }] }) } } But i struggle to pass it correctly. Edited November 24, 2012 by stijn0713 Quote Link to comment https://forums.phpfreaks.com/topic/271103-passing-data-to-function/ Share on other sites More sharing options...
codefossa Posted November 24, 2012 Share Posted November 24, 2012 You are passing an array with an array in it. You don't enclose the {} with [] unless you're doing multiple arrays. If you want multiple array with keys then you would be doing {} inside of {}. var data = { "name": "hein frank" }; Also, you forget a lot of your delimiters. I know sometimes you can get away with it, but you should just use them all the time to avoid confusion. It doesn't hurt anything to have it, but it can hurt it to not. Quote Link to comment https://forums.phpfreaks.com/topic/271103-passing-data-to-function/#findComment-1394785 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.