Welcome, Guest
Username: Password: Remember me

TOPIC: JQuery Autocomplete problem!

JQuery Autocomplete problem! 3 months 3 weeks ago #111306

  • edwardk
  • edwardk's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 8
  • Karma: 0
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>
The administrator has disabled public write access.

JQuery Autocomplete problem! 3 months 3 weeks ago #111309

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6551
  • Thank you received: 868
  • Karma: 257
Hi,

Try:
var url = "/templates/default/mysql/getstudentid.php";
What is the complete iurl of this link ?
The administrator has disabled public write access.

JQuery Autocomplete problem! 3 months 3 weeks ago #111312

  • edwardk
  • edwardk's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 8
  • Karma: 0
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.
The administrator has disabled public write access.

JQuery Autocomplete problem! 3 months 3 weeks ago #111314

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6551
  • Thank you received: 868
  • Karma: 257
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 ?
Last Edit: 3 months 3 weeks ago by DenisChenu.
The administrator has disabled public write access.

JQuery Autocomplete problem! 3 months 3 weeks ago #111315

  • edwardk
  • edwardk's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 8
  • Karma: 0
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"}
The administrator has disabled public write access.

JQuery Autocomplete problem! 3 months 3 weeks ago #111316

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6551
  • Thank you received: 868
  • Karma: 257
Try with item.studentid
jqueryui.com/autocomplete/#remote
But a link can be cool too ...
The administrator has disabled public write access.

JQuery Autocomplete problem! 3 months 3 weeks ago #111317

  • edwardk
  • edwardk's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 8
  • Karma: 0
DenisChenu wrote:
Try with item.studentid
jqueryui.com/autocomplete/#remote
But a link can be cool too ...

Thank you so much!
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.513 seconds
Donation Image