Hi, I'm a jquery newbie, and I'm having trouble making the autocomplete
plugin working with cross-domain calls.  The alert in my callback function
is never executed.  Can't figure out why!

Here's the plugin I'm using:
http://plugins.jquery.com/project/jq-autocomplete

Here's the simple JSON data returned from external server
http://include.classistatic.com/include/c3js/classifieds/rel1/auto/a/p3.js:

{"kjq":["apple1","apple2","apple3","apple4","apple5","apple6","apple2"]}  
//Let me know if this is invalid JSON

I've modified this line to include a JSONP callback parameter
"jsoncallback=?":
$.getJSON(ajax, "val=" + input.val() + "&jsoncallback=?", function
(json) { alert("Hello");});

What am I doing wrong?

Any help would be appreciated!

Here's my complete code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>
<html>
        <!-- Start of HtmlPageHtmlHead -->
        <head>
                
        </head>
<body > 
<table border="0" cellpadding="0" cellspacing="0" valign="top" width="100%">
<tr>
        <td nowrap="true"  width="60%">
                        <input type="text" name="Keyword" value="" 
class="keyword">
        </td>
</tr>
</table>
                        <script
src="http://include.classistatic.com/include/c3js/classifieds/rel1/jquery-1.2.6.js";></script>
                        <script>
                        //This part is from jquery.ui.autocomplete.ext.js
                        (function($) {
                                $.ui = $.ui || {};
                                $.ui.autocomplete = $.ui.autocomplete || {};
                                $.ui.autocomplete.ext = $.ui.autocomplete.ext 
|| {};
                                
                                $.ui.autocomplete.ext.ajax = function(opt) {
                                        var ajax = opt.ajax;
                                        return { getList: function(input) { 
                                                $.getJSON(ajax, "val=" + 
input.val() + "&jsoncallback=?",
function(json) { alert("Hello");}); 
                                        } };
                                };
                                
                                $.ui.autocomplete.ext.templateText = 
function(opt) {
                                        var template = 
$.makeTemplate(opt.templateText, "<%", "%>");
                                        return { template: function(obj) { 
return template(obj); } };
                                };
                                
                        })(jQuery);
                        </script>
                        <script type="text/javascript"
src="http://include.classistatic.com/include/c3js/classifieds/rel1/jquery.ui.autocomplete.js";></script>
                        <script type="text/javascript"
src="http://include.classistatic.com/include/c3js/classifieds/rel1/jquery.dimensions.js";></script>
                        <script>
  $(document).ready(function(){
        
$("input.keyword").autocomplete({ajax:"http://include.classistatic.com/include/c3js/classifieds/rel1/auto/a/p3.js"});
                //$("input.keyword").autocomplete({ajax:"p.js"});
  });
  </script>     
        </body>
</html>


-- 
View this message in context: 
http://www.nabble.com/Autocomplete---trouble-with-getJSON-callback-function-not-executing--tp24207659s27240p24207659.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to