CodeIgniter Forums
[ASK] Integrating CI and Jquery autocomplete plugin - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: [ASK] Integrating CI and Jquery autocomplete plugin (/showthread.php?tid=10918)

Pages: 1 2


[ASK] Integrating CI and Jquery autocomplete plugin - El Forum - 08-18-2008

[eluser]Aria Rajasa[/eluser]
Hi all, I am trying to use the jquery autocomplete plugin and found a bit of stuck here. It seems that the plugin uses a $_GET parameter and therefore can't work with the CI URL re-routing. It calls url like this:

http://localhost/SITE/controller/search_fullname?q=joko&limit=10&timestamp=1219101506002

I can't get the variable q to work, but if I can rewrite the url to let's say:

http://localhost/QMIT/plan/search_fullname/joko

then I can just adjust the controller to work accordingly, any hints?

TIA


[ASK] Integrating CI and Jquery autocomplete plugin - El Forum - 08-19-2008

[eluser]gon[/eluser]
Hi,

You can edit the autocomplete plugin to make it use POST.
Just add

type: "post",

to the configuration object sent inside $.ajax( statement, inside request() function.



Or you can enable $_GET this way. I have used it without any problem.

Cheers


[ASK] Integrating CI and Jquery autocomplete plugin - El Forum - 08-19-2008

[eluser]Aria Rajasa[/eluser]
Thank you so much <b>gon</b> for the reply. I use your solution and change it to post and now it works! Thanks again!


[ASK] Integrating CI and Jquery autocomplete plugin - El Forum - 09-07-2008

[eluser]San2k[/eluser]
Hi! I started to work with CI yesterday.

Could you please write a little example of how did you realized this autocomplete feature in CI?

Here where iam stuck - $("#suggest1").autocomplete('/data_work/search_username/',type:"post");
});

So data_work is a cntroller. search_username - function. This function will search for usernames in DB and return it to autocomplete.

I dont know what to do next. I think its necessarily to do something with CI URI routing, but i dont know what exactly Smile


[ASK] Integrating CI and Jquery autocomplete plugin - El Forum - 09-07-2008

[eluser]Aria Rajasa[/eluser]
I am using the jquery autocomplete and edit the jquery.autocomplete.js. I search for:

Code:
$.ajax({type: "get"...

and edit the "get" to "post", and it works! I also encountered another problem with thickbox. So I used the "activating the get functionality" that was also recommended and it also works Big Grin

Hope it helps


[ASK] Integrating CI and Jquery autocomplete plugin - El Forum - 09-07-2008

[eluser]San2k[/eluser]
Yep, did it! Thanks alot!


[ASK] Integrating CI and Jquery autocomplete plugin - El Forum - 09-09-2008

[eluser]GrootBaas[/eluser]
Hi all,

I seem to have the same issue, but I can not find
Code:
$.ajax({type: "get"
anywhere in the jquery.autocomplete.js.

Please can someone help me in the right direction.

Thanks in advance,


[ASK] Integrating CI and Jquery autocomplete plugin - El Forum - 09-10-2008

[eluser]Aria Rajasa[/eluser]
search for

Code:
$.ajax({mode: "abort",port: "autocomplete" + input.name,

and add type: "post" like this

Code:
$.ajax({type: "post", mode: "abort",port: "autocomplete" + input.name,

Works for me


[ASK] Integrating CI and Jquery autocomplete plugin - El Forum - 09-10-2008

[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"]);



[ASK] Integrating CI and Jquery autocomplete plugin - El Forum - 06-14-2009

[eluser]mikeyhell[/eluser]
Adding type: "post", in jquery.autocomplete.js throws an error:

missing } in compound statement

Anyone know why? This seemed to work before and my JS skills aren't good enough to track it down.

Thanks