Jump to content

Passing Data To Function


stijn0713

Recommended Posts

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 by stijn0713
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.