Before I added dataType: "jsonp" my autocomplete was working. Now I need to make it cross domain compatible, thus using jsonp
I’ve added dataType: "jsonp" and ?callback= at the end of the URL.
But I still keep getting this error message:
Notice: Undefined index: callback in /var/www/storelocator/wp-content/themes/storelocator/classes/jquery.class.php on line 101
On line 101 I have the following code:
echo $_GET['callback'] . '('.json_encode($data).')';
My javascript looks like this:
jQuery('.autocomplete_brand').autocomplete({
source: siteURL +"/wp-content/themes/storelocator/include/jquery.php?instance=search_brand&limit=25?callback=",
dataType: "jsonp",
minLength: 2,
search: function(event, ui) { jQuery(this).toggleClass( "autocomplete_loading" ); },
open: function(event, ui) { jQuery(this).toggleClass( "autocomplete_loading" ); },
select: function(event, ui) { jQuery('#ID').val(ui.item.id); }
}).data( "autocomplete" )._renderItem = function( ul, item ) {
return jQuery( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>"+ item.value + "</a>" )
.appendTo( ul );
jQuery(this).toggleClass( "autocomplete_loading" );
}
You have ? instead of & preceding the callback. Thus ‘callback’ is undefined in GET.