JQuery Autocomplete problem!

More
2 years 8 months ago #111306 by edwardk
edwardk created the topic: JQuery Autocomplete problem!
Dear All,

I use jQuery Autocomplete plugin , but somthing wrong in jquery or php mysqli.
Please tell me what wrong in this.

~~ templates/default/mysql/getstudentid.php PHP Mysql Connection ~~
$mysqli = new mysqli('localhost','user','password','myDatabaseName');
$myArray = array();
if ($result = $mysqli->query("SELECT studentid FROM student")) {
 
    while($row = $result->fetch_array(MYSQL_ASSOC)) {
            $myArray[] = $row;
    }
    echo json_encode($myArray);
}
 
$result->close();
$mysqli->close();

~~~ Survey question and "Source" ~~~
Input your student id <script type="text/javascript" charset="utf-8">
 
        $(document).ready(function() {
 
                var qID = 233;
                var url = "templates/default/mysql/getstudentid.php";
                var dataArr = [];
 
                $.getJSON(url,function(data){
 
                        $.each(data,function(i, item){
                                dataArr.push(item);
                        });
 
                        $('#question'+qID+' input.text').autocomplete({
                                source: dataArr
                        });
 
                });
 
        });
 
</script>

Please Log in to join the conversation.

More
2 years 8 months ago #111309 by DenisChenu
DenisChenu replied the topic: JQuery Autocomplete problem!
Hi,

Try:
var url = "/templates/default/mysql/getstudentid.php";
What is the complete iurl of this link ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
2 years 8 months ago #111312 by edwardk
edwardk replied the topic: JQuery Autocomplete problem!

DenisChenu wrote: Hi,

Try:
var url = "/templates/default/mysql/getstudentid.php";
What is the complete iurl of this link ?


Dear Denis Chenu

Thanks your reply.
And I try changed var url "/templates/default/mysql/getstudentid.php" still not work!
No result, No script Error, No Autocomplete list show.

Please Log in to join the conversation.

More
2 years 8 months ago - 2 years 8 months ago #111314 by DenisChenu
DenisChenu replied the topic: JQuery Autocomplete problem!
Then replace url by the real url of this file !
http://example.org/limesurvey/templates/default/mysql/getstudentid.php

And did you have something when you go to this url ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
Last Edit: 2 years 8 months ago by DenisChenu.

Please Log in to join the conversation.

More
2 years 8 months ago #111315 by edwardk
edwardk replied the topic: JQuery Autocomplete problem!

DenisChenu wrote: Then replace url by the real url of this file !

http://example.org/limesurvey/templates/default/mysql/getstudentid.php

And did you have something when you go to this url ?


Dear Denis Chenu,
Full url still not work!
And url
http://example.org/limesurvey/templates/default/mysql/getstudentid.php
is work, can show
[{"studentid":"SID001"},{"studentid":"SID002"},{"studentid":"SID003"}

Please Log in to join the conversation.

More
2 years 8 months ago #111316 by DenisChenu
DenisChenu replied the topic: JQuery Autocomplete problem!
Try with item.studentid
jqueryui.com/autocomplete/#remote
But a link can be cool too ...

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
2 years 8 months ago #111317 by edwardk
edwardk replied the topic: JQuery Autocomplete problem!

DenisChenu wrote: Try with item.studentid
jqueryui.com/autocomplete/#remote
But a link can be cool too ...


Thank you so much!

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now