- Posts: 7
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Autcomplete error "Uncaught typeError"
- jorge_acevedo
- Topic Author
- Offline
- New Member
Less
More
9 years 10 months ago #109821
by jorge_acevedo
Autcomplete error "Uncaught typeError" was created by jorge_acevedo
Hi!
I've been using the autocomplete for quite a while already but for some reason it has stopped working. I went to the limesurvey workarounds manual and updated the script I was using but still get the following error:
fullArray = $.csv.toArrays(data);
Uncaught TypeError: Cannot read property 'toArrays' of undefined.
Thanks for your help!!
The whole code I am using is the following:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Define the CSV filename
var csvName = 'fsa.csv';
// Define some paths
var surveyRoot = location.pathname.split('index.php')[0];
// var templateName = $('head link[href*="template.css"]').attr('href').replace(/\/template.css/, '').split('/templates/')[1];
var csvPath = surveyRoot+'autocomplete/';
// Define the questions
var q1ID = '{QID}';
var q1 = $('#question'+q1ID);
// var q2 = $(q1).nextAll('.text-short:eq(0)');
// var q3 = $(q1).nextAll('.text-short:eq(1)');
// Define the path to the CSV
var url = csvPath+csvName;
// Create an array to hold the CSV rows
var namesArr = new Array();
// Grab the CSV contents
$.get( url, function( data ){
// Convert CSV contents to an array of arrays
fullArray = $.csv.toArrays(data);
// Load the CSV rows array
$(fullArray).each(function(i, item){
namesArr.push(item[0]);
});
// Initialise the autocomplete plugin
$('input.text', q1).autocomplete({
source: namesArr,
});
});
});
</script>
I've been using the autocomplete for quite a while already but for some reason it has stopped working. I went to the limesurvey workarounds manual and updated the script I was using but still get the following error:
fullArray = $.csv.toArrays(data);
Uncaught TypeError: Cannot read property 'toArrays' of undefined.
Thanks for your help!!
The whole code I am using is the following:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Define the CSV filename
var csvName = 'fsa.csv';
// Define some paths
var surveyRoot = location.pathname.split('index.php')[0];
// var templateName = $('head link[href*="template.css"]').attr('href').replace(/\/template.css/, '').split('/templates/')[1];
var csvPath = surveyRoot+'autocomplete/';
// Define the questions
var q1ID = '{QID}';
var q1 = $('#question'+q1ID);
// var q2 = $(q1).nextAll('.text-short:eq(0)');
// var q3 = $(q1).nextAll('.text-short:eq(1)');
// Define the path to the CSV
var url = csvPath+csvName;
// Create an array to hold the CSV rows
var namesArr = new Array();
// Grab the CSV contents
$.get( url, function( data ){
// Convert CSV contents to an array of arrays
fullArray = $.csv.toArrays(data);
// Load the CSV rows array
$(fullArray).each(function(i, item){
namesArr.push(item[0]);
});
// Initialise the autocomplete plugin
$('input.text', q1).autocomplete({
source: namesArr,
});
});
});
</script>
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
9 years 10 months ago #109862
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Autcomplete error "Uncaught typeError"
It doesn't look like the CSV contents are being imported correctly.
What changes were made to the installation before the error appeared?
.
What changes were made to the installation before the error appeared?
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- jorge_acevedo
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
9 years 10 months ago #109894
by jorge_acevedo
Replied by jorge_acevedo on topic Autcomplete error "Uncaught typeError"
Hi Tony,
Thanks for your response.
I just updated limesurvey. I also changed the survey template. But I moved everything as it should be. And I don't get an error of not finding the csv.
I'll provide a link to a test question later today for you to look at.
Thanks!
Thanks for your response.
I just updated limesurvey. I also changed the survey template. But I moved everything as it should be. And I don't get an error of not finding the csv.
I'll provide a link to a test question later today for you to look at.
Thanks!
The topic has been locked.
- jorge_acevedo
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
9 years 10 months ago #109896
by jorge_acevedo
Replied by jorge_acevedo on topic Autcomplete error "Uncaught typeError"
Tony,
Here is the link to the question
research.gbresearch.net/index.php?r=surv...x/sid/629456/lang/en
Here is the link to the question
research.gbresearch.net/index.php?r=surv...x/sid/629456/lang/en
The topic has been locked.
- jorge_acevedo
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
9 years 10 months ago #109905
by jorge_acevedo
Replied by jorge_acevedo on topic Autcomplete error "Uncaught typeError"
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
9 years 10 months ago - 9 years 10 months ago #109924
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Autcomplete error "Uncaught typeError"
A couple of things to check...
1) This line should have a lower-case v in "Var"
2) Because you are using a subdomain, the URL defined in that line leads to research.gbresearch.net/research/autocomplete/fsa.csv which doesn't exist. I think the defined URL should simply be "autocomplete/fsa.csv".
.
1) This line should have a lower-case v in "Var"
Code:
Var url = "research/autocomplete/fsa.csv";
2) Because you are using a subdomain, the URL defined in that line leads to research.gbresearch.net/research/autocomplete/fsa.csv which doesn't exist. I think the defined URL should simply be "autocomplete/fsa.csv".
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 9 years 10 months ago by tpartner.
The topic has been locked.
- jorge_acevedo
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
9 years 10 months ago - 9 years 10 months ago #109943
by jorge_acevedo
Replied by jorge_acevedo on topic Autcomplete error "Uncaught typeError"
I changed it as suggested but still not working.
Any more suggestions?
I would think it stopped working when we changed the limesurvey from gbresearch.net/research to research.gbresearch.net
Do you think it could be the problem? Yet, it seems it finds the file correctly.
Any more suggestions?
I would think it stopped working when we changed the limesurvey from gbresearch.net/research to research.gbresearch.net
Do you think it could be the problem? Yet, it seems it finds the file correctly.
Last edit: 9 years 10 months ago by jorge_acevedo.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
9 years 10 months ago #109959
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Autcomplete error "Uncaught typeError"
Try using an absolute path to the CSV.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- jorge_acevedo
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
9 years 10 months ago #109973
by jorge_acevedo
Replied by jorge_acevedo on topic Autcomplete error "Uncaught typeError"
Pardon my ignorance. But how do I do that?
The topic has been locked.
- jorge_acevedo
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
9 years 10 months ago - 9 years 10 months ago #109992
by jorge_acevedo
Replied by jorge_acevedo on topic Autcomplete error "Uncaught typeError"
Tony,
Just wanted to let you know that I was able to fix it.
What I did:
I was using the jquery.csv.js version .5 that is posted on the limesurvey wiki
code.google.com/p/jquery-csv/source/brow...77f1d747bc860b943fe7
Apparently that's an old code.
I found in google a new version 0.71
code.google.com/p/jquery-csv/downloads/d...csv-0.71.js&can=2&q=
I replaced the old version for the new one and my autocomplete started working!!!
Thanks for your support.
Just wanted to let you know that I was able to fix it.
What I did:
I was using the jquery.csv.js version .5 that is posted on the limesurvey wiki
code.google.com/p/jquery-csv/source/brow...77f1d747bc860b943fe7
Apparently that's an old code.
I found in google a new version 0.71
code.google.com/p/jquery-csv/downloads/d...csv-0.71.js&can=2&q=
I replaced the old version for the new one and my autocomplete started working!!!
Thanks for your support.
Last edit: 9 years 10 months ago by jorge_acevedo. Reason: changed mispelling
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
9 years 10 months ago #109998
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Autcomplete error "Uncaught typeError"
Thanks. I've updated the links on the Workaround page.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.