$(document).ready(function(){
jQuery("#name").autocomplete({
source: function(request, response) {
$.ajax({
url: 'include/get.php',
type: "POST",
data: {
term : request.term,
data :$("#form1").serializeArray()
},
success: function(data) {
data=JSON.parse(data);
response(data);
}
});
},
minlength:1
});
});
Here onclick of field 'name' it calls an ajax file get.php where it sends the form data and the entered term.
The response we get which is in json format is again parsed as
data=JSON.parse(data);
to get the result otherwise it shows jquery error,means the data is parsed as json twice to display the autocomplete result correctly.
0 Comment(s)