尝试JSON编码Ajax函数发送值

I am using a hidden field and appending values with the following function.

 $( "#invite_suggestion" ).autocomplete({
    source: BASEURL + 'index.php/search_contacts_suggestion/',
    select: function( event, ui )
    {

      $('#invite_id').val($('#invite_id').val()+ui.item.friend_id); 

    }
});

In the PHP side

$_POST['invite_id']=(isset($_POST['invite_id']))?json_encode(array($_POST['invite_id'])):json_encode(NULL);

But Actually the final output of this is string ["4565"] and what i actually need is to JSON encode of individual values in field ["45","65"]

seperate the values by a comma in your js:

$('#invite_id').val($('#invite_id').val()+','+ui.item.friend_id);

then explode on the comma in php to create the array:

(isset($_POST['invite_id']))?json_encode(explode(',',$_POST['invite_id'])):json_encode(NULL);

on the PHP side I expect you'll want to do an 'explode' on the $_POST['invide_id'] to get an array of elements. $_POST['BLAH'] will only return a string.

e.g. something like...

$_POST['invite_id']=(isset($_POST['invite_id']))?json_encode(explode($_POST[',', 'invite_id']))):json_encode(NULL);