php - Trying JSON Encoding of Ajax function sending values -
i using hidden field , appending values next 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 php side
$_post['invite_id']=(isset($_post['invite_id']))?json_encode(array($_post['invite_id'])):json_encode(null);
but final output of string ["4565"] , need json encode of individual values in field ["45","65"]
seperate values comma in js:
$('#invite_id').val($('#invite_id').val()+','+ui.item.friend_id);
then explode on comma in php create array:
(isset($_post['invite_id']))?json_encode(explode(',',$_post['invite_id'])):json_encode(null);
php ajax json
No comments:
Post a Comment