user2355647
user2355647

Reputation: 1

CodeIgniter + Jquery + autocomplete no results

I'm using codeigniter and i've created a simple input with jquery ui autocomplete to show some results.

I'm just doing tests just to be sure that i could use this tool.

I've done this:

//in head
<script src="/js/jquery-1.9.1.js"></script>
<script src="/js/jquery-ui.js"></script>


//in body
<script type="text/javascript">
$(function() {

    var tags = [
    "ActionScript",
    "AppleScript",
    "Asp",
    "BASIC",
    "C",
    "C++",
    "Clojure",
    "COBOL",
    "ColdFusion",
    "Erlang",
    "Fortran",
    "Groovy",
    "Haskell",
    "Java",
    "JavaScript",
    "Lisp",
    "Perl",
    "PHP",
    "Python",
    "Ruby",
    "Scala",
    "Scheme"
    ];

    $("#autocomplete").autocomplete({
        source: tags
    });
});
</script>

<input id="autocomplete" />

but this is displaying no results!

In chrome dev tools -> network, i see that a request is done and is also getting status 200. So, why this is not displaying results?

In static blank html file with these lines, i'm getting the results!

thanks

Upvotes: 0

Views: 290

Answers (1)

writeToBhuwan
writeToBhuwan

Reputation: 3281

HAve you added the CSS file for jQuery UI?

Add this in your <head> tag:

<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />

Also, If you've already included the CSS already but forgot to mention that in your question, Please replace

<script src="/js/jquery-1.9.1.js"></script>
<script src="/js/jquery-ui.js"></script>

with

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

I seriously doubt that the version of jquery and jQuery UI you are using are not compatible to each other.

Also, Please clean your browser cache before trying the above methods. :)

Edit:

Please make sure that you've declared the document type.

Put this before the <head> tag

<!DOCTYPE html>

Upvotes: 1

Related Questions