Welcome Guest, Not a member yet? Register   Sign In
JQuery auto complete
#1

[eluser]GrootBaas[/eluser]
Hi there,

I would really appreciate any help.

It seems that the jQuery plugin uses a $_GET parameter and therefore can’t work with the CI URL re-routing.

It has been mentioned to change

Code:
$.ajax({type: "get"
to
Code:
$.ajax({type: "post"
in the jquery.autocomplete.js, but I can find no such statement.

Help me please ....
#2

[eluser]Pascal Kriete[/eluser]
jQuery defaults to GET, so it isn't specified. You'll have to add that parameter.
Code:
$.ajax({
    // try to leverage ajaxQueue plugin to abort previous requests
    mode: "abort",
    // limit abortion to this input
    port: "autocomplete" + input.name,
    type: "post",
....
#3

[eluser]GrootBaas[/eluser]
Guys,

Thank you so much for your help. You really make a difference in somebody's live with the fast and educated replies. Thank you all again.

For the next person who comes across this problem ...

Inside jquery.autocomplete.js

Change
Code:
$.ajax({mode: "abort",
    port: "autocomplete" + input.name,
    dataType: options.dataType,
    url: options.url,
    data: $.extend({
    q: lastWord(term),
    limit: options.max
    }, extraParams),
    success: function(data) {
    var parsed = options.parse && options.parse(data) || parse(data);
               cache.add(term, parsed);
             success(term, parsed);
                }
});

to this ...

Code:
$.ajax({type: "post",
        mode: "abort",
    port: "autocomplete" + input.name,
    dataType: options.dataType,
    url: options.url,
    data: $.extend({
    q: lastWord(term),
    limit: options.max
    }, extraParams),
    success: function(data) {
    var parsed = options.parse && options.parse(data) || parse(data);
               cache.add(term, parsed);
             success(term, parsed);
                }
});

Then in your controller, change ....

Code:
$q = strtolower($_GET["q"]);
to
Code:
$q = strtolower($_POST["q"]);
#4

[eluser]JulianM[/eluser]
Great, it worked successfully.

Thanks,

Julian

PS: You can use $_REQUEST in case you want to preserve both methods in the logic.

Quote:$q = strtolower($_REQUEST["q"]);
#5

[eluser]Delete Me Please[/eluser]
Could someone give me a quick example of the function in a controller used for this? I think I'm way off base with what I've got and I'm actually kind of embarrassed to post it heh.
#6

[eluser]@li[/eluser]
Or you can just use Xajax, its heaps better in my experience
#7

[eluser]Delete Me Please[/eluser]
*EDIT*
Ohhh, ya, I don't want to stray away from jQuery. Think I'm gonna keep using it instead of going to another framework. Thanks for the suggestion though.
#8

[eluser]edwardmolasses[/eluser]
Mine works in firefox but i can't get it working in ie. Does anyone else have this problem?




Theme © iAndrew 2016 - Forum software by © MyBB